Alternative for alfresco/service/api/upload in alfresco 5.1 community

cancel
Showing results for 
Search instead for 
Did you mean: 
prasobhraj
Established Member

Alternative for alfresco/service/api/upload in alfresco 5.1 community

Jump to solution

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

1 Solution

Accepted Solutions
jpotts
Professional

Re: Alternative for alfresco/service/api/upload in alfresco 5.1 community

Jump 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.

View solution in original post

6 Replies
mehe
Senior Member II

Re: Alternative for alfresco/service/api/upload in alfresco 5.1 community

Jump to solution

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...

prasobhraj
Established Member

Re: Alternative for alfresco/service/api/upload in alfresco 5.1 community

Jump to solution

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://IPSmiley TongueORT/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

mehe
Senior Member II

Re: Alternative for alfresco/service/api/upload in alfresco 5.1 community

Jump to solution

...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)

jpotts
Professional

Re: Alternative for alfresco/service/api/upload in alfresco 5.1 community

Jump 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.

prasobhraj
Established Member

Re: Alternative for alfresco/service/api/upload in alfresco 5.1 community

Jump to solution

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 .

mehe
Senior Member II

Re: Alternative for alfresco/service/api/upload in alfresco 5.1 community

Jump to solution

Hi, 

glad you've got it working. The shortened "id" is now present in nearly the whole new REST APIs.