diff --git a/src/backend/base/langflow/load/utils.py b/src/backend/base/langflow/load/utils.py index 8050ba51e..11c04c6c4 100644 --- a/src/backend/base/langflow/load/utils.py +++ b/src/backend/base/langflow/load/utils.py @@ -22,7 +22,7 @@ def upload(file_path, host, flow_id): url = f"{host}/api/v1/upload/{flow_id}" with open(file_path, "rb") as file: response = httpx.post(url, files={"file": file}) - if response.status_code == 200: + if response.status_code == 200 or response.status_code == 201: return response.json() else: raise Exception(f"Error uploading file: {response.status_code}") @@ -55,7 +55,7 @@ def upload_file(file_path: str, host: str, flow_id: str, components: list[str], if response["file_path"]: for component in components: if isinstance(component, str): - tweaks[component] = {"file_path": response["file_path"]} + tweaks[component] = {"path": response["file_path"]} else: raise ValueError(f"Component ID or name must be a string. Got {type(component)}") return tweaks diff --git a/src/frontend/src/modals/apiModal/utils/get-python-api-code.tsx b/src/frontend/src/modals/apiModal/utils/get-python-api-code.tsx index 4ac41b235..3482e8b0e 100644 --- a/src/frontend/src/modals/apiModal/utils/get-python-api-code.tsx +++ b/src/frontend/src/modals/apiModal/utils/get-python-api-code.tsx @@ -95,7 +95,7 @@ def main(): raise ImportError("Langflow is not installed. Please install it to use the upload_file function.") elif not args.components: raise ValueError("You need to provide the components to upload the file to.") - tweaks = upload_file(file_path=args.upload_file, host=BASE_API_URL, flow_id=ENDPOINT, components=args.components, tweaks=tweaks) + tweaks = upload_file(file_path=args.upload_file, host=BASE_API_URL, flow_id=args.endpoint, components=[args.components], tweaks=tweaks) response = run_flow( message=args.message,