cancel
Showing results for 
Search instead for 
Did you mean: 

uploading content

tog
Champ in-the-making
Champ in-the-making
Hi,

I know there is a web service interface to alfresco but I was wondering if it was possible to upload content using either a command line (curl for example) or by doing a POST request to the server ?

Cheers
Tog
19 REPLIES 19

mikeh
Star Contributor
Star Contributor
Look at the root of the exception: org.alfresco.repo.jscript.ScriptNode.createFile(ScriptNode.java:1237). (AlfrescoScript#34) also gives you a hint that the script is running but encountered a problem on line 34.

It's simply that the user you're running the script with doesn't have permissions to create content in Company Home.

Thanks,
Mike

tog
Champ in-the-making
Champ in-the-making
Ok Mike,

But there is something I don't understand. Usually when I try to run such a script I am prompted with a pop-up for entering login/password ? In that case not ? Which is the user being used for this action ?

Assuming that I might have been using a previous script with credentials not allowing access to Company Home, how can I terminate the current session from the browser ?

Thanks

tog
Champ in-the-making
Champ in-the-making
Ok I manage to be logged with admin who has the proper right …
But I get a new error:

Exception:   org.alfresco.error.AlfrescoRuntimeException - Java class "org.alfresco.repo.jscript.ScriptNode$ScriptContentData" has no public instance field or method named "encoding". (AlfrescoScript#36)
   
org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:535)

There is nothing like "encoding" being defined in the webscript.

Any idea ? or should I dig in the source

Thanks

rhofkens
Champ in-the-making
Champ in-the-making
Hi,

I've run into the same problem before, the encoding field is probably not implemented in the version of alfresco that you're using.
Have a look at this post: http://forums.alfresco.com/viewtopic.php?f=36&t=9768

Cheers,
Roeland

tog
Champ in-the-making
Champ in-the-making
Thanks Roeland
This is working like a charm. Next step is to upload 16GB Smiley Happy

Cheers
Guillaume

tog
Champ in-the-making
Champ in-the-making
Ok so actually uploading 16GB does not work out of the box. Actually the limit seems to be around 2 GB (1GB and 1.5GB are working fine).
Does someone knows how this is working underneath ? Is the file loaded into memory ? What is the limiting factor ? - the memory of my local machine ?
I should be able to stream my data isn't it hence my other post which is not yet populat Smiley Happy

Cheers
Guillaume

tog
Champ in-the-making
Champ in-the-making
Ok so most (if not all) browsers have this 2GB limit. I will move to a custom client for uploading files.
Guillaume

agatap
Champ in-the-making
Champ in-the-making
Is there any way to upload a file from a form using java - we don't plan on using javascript in our application?
I cant see how to access the input stream from a DeclarativeWebScript.

Best,
Agata

tog
Champ in-the-making
Champ in-the-making
Yes this is possible. This is #2 on my TODO list. #1 is a java client to upload files larger than 2GB.
I will post the status later on

Cheers
Guillaume

tog
Champ in-the-making
Champ in-the-making
Smiley Sad   :arrow:  I need help !

So in order to circumvent the browser limitation, I have a small client that is able to post a large file to Alfresco …. but large is still smaller because I was not able to write a Java-based webscript using apache commons upload to stream the file.

Here is the pseudo code

public class UploadWebScript extends AbstractWebScript {
    public void execute(WebScriptRequest request, WebScriptResponse response) throws IOException {

       HttpServletRequest httpRequest = ((WebScriptServletRequest)request).getHttpServletRequest();
  
        ServletFileUpload upload = new ServletFileUpload(new DiskFileItemFactory());
        upload.setHeaderEncoding("UTF-8");

        try {
            logger.info("parsing http request");
            List<FileItem> fileItems = upload.parseRequest(httpRequest);
….
    }
}


fileItems remains an empty list …???

Similarly, request.getParameter("file") is null !

Can someone told what I am doing wrong here ?

Cheers
Guillaume