Upload a File
You can upload a file from your local system to an existing folder in the Catalyst File Store, by referring to its unique folder ID. You can upload an image, text document, CSV, or any type of file you need.
The maximum size of a file that you can upload is 100 MB. A unique file ID is created for the file after it is uploaded.
Create a Dictionary
You must initially create a dictionary for the file to be uploaded, as shown below. The dictionary contains a key value that stores the file object returned on opening the input file using the open() function.
copyconfig = { 'code': open('file.txt', "rb"), 'name': 'testFile.txt' }
Upload the File
You can upload the file by passing the configured dictionary to the upload_file() method, as shown below.
You can either use the component reference or the folder reference created earlier, to refer the folder where the file needs to be uploaded in. You must pass the unique folder ID of the folder. The response returned here will be the information of the uploaded file.
The filestore_service reference used below is already defined in the component instance page.
copy#Upload a file file = open('file.txt', "rb") folder = filestore_service.folder(6759000000166049) folder.upload_file('testFile.txt',file)
A sample response is shown below :
copy{ id: "5249000000016011", file_location: null, file_name: "testFile.txt", file_size: "84881", created_by: { zuid: "66466723", is_confirmed: false, email_id: "amelia.burrows@zylker.com", first_name: "Amelia", last_name: "Burrows", user_type: "Admin", user_id: "2136000000006003" }, created_time: "Aug 17, 2021 09:33 PM", modified_by: { zuid: "66466723", is_confirmed: false, email_id: "amelia.burrows@zylker.com", first_name: "Amelia", last_name: "Burrows", user_type: "Admin", user_id: "2136000000006003" }, modified_time: "Aug 17, 2021 09:33 PM", project_details: { project_name: "ShipmentTracking", id: "2136000000007733" }, folder_details: "5249000000016011" }
Last Updated 2023-12-18 16:20:08 +0530 +0530
Yes
No
Send your feedback to us