cancel
Showing results for 
Search instead for 
Did you mean: 

Upload large files using Alfresco

amit10may
Champ in-the-making
Champ in-the-making
Hi,
We are using Alfresco CE 3.2 with WebService API from Java webapplication.
Right now the business use case is to upload few documents to Alfresco and its size can vary from 1MB to 100MB.
Our current implementation uses ContentService's
public Content write(Reference node, String property, byte[] content, ContentFormat format) throws RemoteException, ContentFault
API.
Problem with this approach is that the file content has to be loaded completely in byte array and only then can be written to alfresco.
This can become a pain for server esp for large files under heavy load.
Ideally it should be possible to use a stream based approach (as can be done for download content)
I figured out that there is a concept of UploadServlet which can be used to upload content but was not able to understand how to do that by reading the short documentation.

Can someone explain me what is the best way to deal with large file uploads using WebService APIs?
Sample code would be a boon Smiley Happy

Regards,
Amit
11 REPLIES 11

mrogers
Star Contributor
Star Contributor
WebServices are not suitable for large files.     You need to use one of the streaming interfaces.

akoudrin
Champ in-the-making
Champ in-the-making
Could you tell me which interface is best to use to upload a 200MB file to Alfresco4.0.c? If you have a code snippet (including the imports) that would be even better.

amit10may
Champ in-the-making
Champ in-the-making
Wow..I did not expect such a quick reply.. so thanks a lot Smiley Happy
Can you please give me some pointer to where I can look for help on streaming interface?
I want to integrate it with my Java web application (in fact spring based services are client of the alfresco api)

junieboy
Champ in-the-making
Champ in-the-making
Hi Amit,

Could I ask you in which javadoc would I find the org.alfresco.webservices classes? I am currently using Alfresco CE 3.0 and am not able to see any javadoc for the NamedValue, CMLCreate, UpdateResult, etc? Also, could you further elaborate on the approach below?

Thanks in advance.

junieboy
Champ in-the-making
Champ in-the-making
WebServices are not suitable for large files.     You need to use one of the streaming interfaces.


What do you mean when you say "the streaming interfaces" ? Are these the Java InputStream, OutputStream interfaces? Please elaborate. Thanks.

openpj
Elite Collaborator
Elite Collaborator
Yes, you can use the upload servlet to stream the content using a PUT HTTP method:
http://wiki.alfresco.com/wiki/URL_Addressability#UploadContentServlet
Hope this helps.

junieboy
Champ in-the-making
Champ in-the-making
Yes, you can use the upload servlet to stream the content using a PUT HTTP method:
http://wiki.alfresco.com/wiki/URL_Addressability#UploadContentServlet
Hope this helps.


Hi,

How does this impact the attaching of the metadata to the files? We need these functionalities: save big files to Alfresco and use metadata for searching in the content repository (a custom content model will be created for  this). The metadata will come from an external system w/c will invoke the Alfresco web services API.

Thanks so much for your response.

Best regards,
Junie

mwildam
Champ in-the-making
Champ in-the-making
How does this impact the attaching of the metadata to the files? We need these functionalities: save big files to Alfresco and use metadata for searching in the content repository (a custom content model will be created for  this). The metadata will come from an external system w/c will invoke the Alfresco web services API.
You can combine these APIs - I do also. For the upload via you just specify the documents uuid and upload the file - so it is "compatible" with the rest done through web services API.

junieboy
Champ in-the-making
Champ in-the-making
How does this impact the attaching of the metadata to the files? We need these functionalities: save big files to Alfresco and use metadata for searching in the content repository (a custom content model will be created for  this). The metadata will come from an external system w/c will invoke the Alfresco web services API.
You can combine these APIs - I do also. For the upload via you just specify the documents uuid and upload the file - so it is "compatible" with the rest done through web services API.

Hi Martin! Thanks so much for the response. Would you mind if I ask you to post sample code/implementations you have? If it's fine to ask for your source, my email is junieboy@gmail.com.

Regards.