Upload a file to a specific folder

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Active Member

Upload a file to a specific folder

Hi, i'm using alfresco 5.2 and i'm using rest api. I recently developed my software to upload a file to admin file manager. What i want to do right now is, upload my file to a specific folder in admin. 

Imagine i have a folder named "reports" and my files should upload to "reports" folder.

File upload as "filedata" and i tried to provide "destination" as "sample" and it wont upload my file to "sample" folder. It just upload to the root of the folder. I provided my folder nodeRef as folder nodeRef. And then i tried to upload back again using "uploaddirectory" and for this i provided "sample" which is my folder name. But nothing worked. 

What should i do in my case ?

1 Reply
Highlighted
Moderator
Moderator

Re: Upload a file to a specific folder

"destination" should be the nodeRef of the target folder. 

If you are  uploading to a site, then siteId and container id can be provided. Else you can pass nodeRef of the existing folder using destination parameter.

You can use "uploaddirectory" in combination with either destination or siteid and containerid (if uploading to a site). where upload directory is a subfolder

 

Here is the detailed description for upload api:

Upload file content and meta-data into repository.

POST /alfresco/service/api/upload

 

HTML form data
  • filedata, (mandatory) HTML type file
  • You must specify one of:
    • destination (the folder NodeRef where the node will be created)
    • updateNodeRef (the NodeRef of an existing node that will be updated)
    • siteid and containerid (the Site name and the container in that site where the document will be created)
  • uploaddirectory - name of the folder (either in the site container or the destination) where the document will be uploaded. This folder must already exist
  • description - Description for a version update (versionDescription)
  • contenttype - The content type that this document should be specialised to
  • majorversion
  • overwrite
  • thumbnails
Return content
  • nodeRef

Return status: STATUS_OK (200)

The web script description document specifies the following options:
Value Description
json The default response format
user The authentication access
required The transaction level
any The format style
~Abhinav
(ACSCE, AWS SAA-C02)
https://javaworld-abhinav.blogspot.com