fix: add support for upload flows to a folder (#2844)
* ✨ (flows.py): Add support for uploading flows to a specific folder by adding a folder_id parameter to the upload_file function and updating the flow object with the folder_id if provided 📝 (use-on-file-drop.tsx): Update import statements to include the new uploadFlowToFolder function and replace the usage of uploadFlowsFromFolders with uploadFlowToFolder 🔧 (use-drag-and-drop.tsx): Refactor the useDragAndDrop hook to remove unnecessary code related to file handling ⬆️ (index.ts): Add a new function uploadFlowToFolder to handle uploading flows to a specific folder in the MainPage services module * ♻️ (flows.py): remove trailing whitespace to maintain code cleanliness and consistency
This commit is contained in:
parent
9731ebb27d
commit
41143b1e58
4 changed files with 33 additions and 17 deletions
|
|
@ -293,10 +293,12 @@ async def upload_file(
|
|||
session: Session = Depends(get_session),
|
||||
file: UploadFile = File(...),
|
||||
current_user: User = Depends(get_current_active_user),
|
||||
folder_id: UUID | None = None,
|
||||
):
|
||||
"""Upload flows from a file."""
|
||||
contents = await file.read()
|
||||
data = orjson.loads(contents)
|
||||
response_list = []
|
||||
if "flows" in data:
|
||||
flow_list = FlowListCreate(**data)
|
||||
else:
|
||||
|
|
@ -304,8 +306,12 @@ async def upload_file(
|
|||
# Now we set the user_id for all flows
|
||||
for flow in flow_list.flows:
|
||||
flow.user_id = current_user.id
|
||||
if folder_id:
|
||||
flow.folder_id = folder_id
|
||||
response = create_flow(session=session, flow=flow, current_user=current_user)
|
||||
response_list.append(response)
|
||||
|
||||
return create_flows(session=session, flow_list=flow_list, current_user=current_user)
|
||||
return response_list
|
||||
|
||||
|
||||
@router.get("/download/", response_model=FlowListRead, status_code=200)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue