Hi,
I was using alfresco 4.2 community and used the api alfresco/service/api/upload for uploading documents from external apps to alfresco. Now its upgraded to 5.1 . but the api changed. please help me to get the alternative to upload the document using api.
Thanks,
Prasobh
Solved! Go to Solution.
You should be using CMIS for this. Grab a library from Apache Chemistry and then use the library from your apps that need to create, read, update, and delete documents (including getting/setting properties) from the Alfresco repository.
CMIS works with 4.2 as well as newer versions and is much more stable than any other API available for Alfresco.
alfresco/service/api/upload is still there - should work as usual.
curl -u ALFUSER:ALFPW -X POST -F filedata=@TheFile -F destination="NoderefOfTheFolderUploadingTo" "http://theHost:port/alfresco/service/api/upload"
You could write your own upload web script like in Processing multipart forms | Alfresco Documentation
or, if you are in JS context, use alfresco-js-api.js uploadFile GitHub - Alfresco/alfresco-js-api: This project provides a JavaScript client API into the Alfresco R...
I just saw: The last option is not true, you would need 5.2 for the JS lib...
Hi,
am getting the below error
{
"status" :
{
"code" : 500,
"name" : "Internal Error",
"description" : "An error inside the HTTP server which prevented it from fulfilling the request."
},"message" : "030323762 Unexpected error occurred during upload of new content.",
"exception" : "","callstack" :
[],
"server" : "Community v5.1.0 (r127059-b7) schema 10,001",
"time" : "Apr 3, 2017 12:56:35 PM"
}
i was using python code to upload which was successful for 4.2.
upload_file = open(folder+secure_filename(file), 'rb')
url = "http://IPORT/alfresco/service/api/upload"
auth = (USERNAME, PASSWORD)
files = {"filedata": upload_file}
data = {"destination": id of space to upload}
r = requests.post(url, files=files, data=data, auth=auth)
Please advice if there any changes to be made
...and this is exactly the way it should work.
Is destination in the form "workspace://SpacesStore/..." and really existing? (not existing should give Error 400)
Since it's an internal server error: anything in the alfresco logs - most likely a permission problem or error in a rule script? (catalina.out, alfresco.log)
You should be using CMIS for this. Grab a library from Apache Chemistry and then use the library from your apps that need to create, read, update, and delete documents (including getting/setting properties) from the Alfresco repository.
CMIS works with 4.2 as well as newer versions and is much more stable than any other API available for Alfresco.
Hi,
I was using cmislib for getting the node id of the space where the documents to be uploaded. In 4.2 node.id was returning workspace://SpacesStore/xxxxxxxxxxxxxx. but in 5.1 it just returns xxxxxxxxxxxxxxxxxx. this one i changed to node.getProperties()["alfcmis:nodeRef"]. noW it got worked .
Hi,
glad you've got it working. The shortened "id" is now present in nearly the whole new REST APIs.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.