cancel
Showing results for 
Search instead for 
Did you mean: 

Rest API - Upload file to specific folder of a site

ludoADV
Confirmed Champ
Confirmed Champ

Hello,

I try to upload a file to folder 'documentLibrary/CERTs' defined to '0' site using following cURL command:

curl -X POST -F filedata=@test2.txt -F ‘nodeType=\"cm:content\"’ -F ‘relativePath=\"CERTs\"’ -H 'Authorization: Basic VElDS0VUXzUyMzU1YmE4NzhkOWEwMTNmNjk4MjNjYTRiZGY5YjNiMDdkNmJjNWM=' http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children

test2.txt document is correctly uploaded but in '/' repository, not in '/Sites/0/documentLibrary/CERTs' folder.

My ACS instance is running on Community 7.1.0

 

 

 

1 ACCEPTED ANSWER

abhinavmishra14
World-Class Innovator
World-Class Innovator

@ludoADV wrote:

Hello,

I try to upload a file to folder 'documentLibrary/CERTs' defined to '0' site using following cURL command:

curl -X POST -F filedata=@test2.txt -F ‘nodeType=\"cm:content\"’ -F ‘relativePath=\"CERTs\"’ -H 'Authorization: Basic VElDS0VUXzUyMzU1YmE4NzhkOWEwMTNmNjk4MjNjYTRiZGY5YjNiMDdkNmJjNWM=' http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children

test2.txt document is correctly uploaded but in '/' repository, not in '/Sites/0/documentLibrary/CERTs' folder.

My ACS instance is running on Community 7.1.0

 


The correct way is the below examples, you have to provide the site (testsite is the siteshortname and myfolder after documentLibraryis the folder where file needs to be uploaded) with foldername path for relativePath param, see example below:

$ curl -X POST -F filedata=@test2.txt -F "name=somefile.txt" -F "nodeType=cm:content" -F "cm:title=My text" -F "cm:description=My text document description" -F "relativePath=/Sites/testsite/documentLibrary/myfolder" http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?alf_ticket=TICKET_455c2e0153a24170466005a9b9326607cee59674

OR

$ curl -X POST -F filedata=@test2.txt -F "name=somefile.txt" -F "nodeType=cm:content" -F "cm:title=My text" -F "cm:description=My text document description" -F "relativePath=/Sites/testsite/documentLibrary/myfolder" -H 'Authorization: Basic VElDS0VUXzQ1NWMyZTAxNTNhMjQxNzA0NjYwMDVhOWI5MzI2NjA3Y2VlNTk2NzQ=' http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children
~Abhinav
(ACSCE, AWS SAA, Azure Admin)

View answer in original post

1 REPLY 1

abhinavmishra14
World-Class Innovator
World-Class Innovator

@ludoADV wrote:

Hello,

I try to upload a file to folder 'documentLibrary/CERTs' defined to '0' site using following cURL command:

curl -X POST -F filedata=@test2.txt -F ‘nodeType=\"cm:content\"’ -F ‘relativePath=\"CERTs\"’ -H 'Authorization: Basic VElDS0VUXzUyMzU1YmE4NzhkOWEwMTNmNjk4MjNjYTRiZGY5YjNiMDdkNmJjNWM=' http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children

test2.txt document is correctly uploaded but in '/' repository, not in '/Sites/0/documentLibrary/CERTs' folder.

My ACS instance is running on Community 7.1.0

 


The correct way is the below examples, you have to provide the site (testsite is the siteshortname and myfolder after documentLibraryis the folder where file needs to be uploaded) with foldername path for relativePath param, see example below:

$ curl -X POST -F filedata=@test2.txt -F "name=somefile.txt" -F "nodeType=cm:content" -F "cm:title=My text" -F "cm:description=My text document description" -F "relativePath=/Sites/testsite/documentLibrary/myfolder" http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children?alf_ticket=TICKET_455c2e0153a24170466005a9b9326607cee59674

OR

$ curl -X POST -F filedata=@test2.txt -F "name=somefile.txt" -F "nodeType=cm:content" -F "cm:title=My text" -F "cm:description=My text document description" -F "relativePath=/Sites/testsite/documentLibrary/myfolder" -H 'Authorization: Basic VElDS0VUXzQ1NWMyZTAxNTNhMjQxNzA0NjYwMDVhOWI5MzI2NjA3Y2VlNTk2NzQ=' http://localhost:8080/alfresco/api/-default-/public/alfresco/versions/1/nodes/-root-/children
~Abhinav
(ACSCE, AWS SAA, Azure Admin)