cancel
Showing results for 
Search instead for 
Did you mean: 

File Upload Error

dryok
Champ in-the-making
Champ in-the-making
Hi.

I'm new using Alfresco, and I need to upload a file whith Java.

First, I have tried using Web Service and it's works fine, but when i try to upload files whith size of 2.5 MB or more I receive an axis Java Heap Space error. I get that error too with slower size files if I launch some uploads concurrently.

Now I'm trying to upload using the RestApi. I use the Web Script /alfresco/service/api/upload but i'm receiving an error 500(Internal Error):An error inside the HTTP server which prevented it from fulfilling the request.

I tried using a simple HTML form as indicates the Web Script description in /alfresco/service/index/all:
File Upload
POST /alfresco/service/api/upload

Upload file content and meta-data into repository.
HTML form data

    * filedata, (mandatory) HTML type file
    * siteid
    * containerid
    * uploaddirectory
    * updatenoderef
    * filename
    * description
    * contenttype
    * majorversion
    * overwrite
    * thumbnails

So I created the follow HTML form:
<html>
   <body>
      <form method="post" action="http://localhost:8080/alfresco/service/api/upload?alf_ticket=TICKET_405f319152813bc46da98266b83777cf..." >
         <input type="file" name="filedata" />
         <input type="hidden" name="description" value="a description" />
         <input type="hidden" name="filename" value="myFile" />
         <input type="hidden" name="containerid" value="af05cb2c-8100-442c-8dce-de81a8de57b0"/>
         <input type="submit" name="submit" value="upload" />
      </form>
   </body>
</html>

But when i submit it I get the error An error inside the HTTP server which prevented it from fulfilling the request.


I tried using Java, and I code the follow:
        // Instancite object
        DefaultHttpClient httpClient = new DefaultHttpClient();
       
        // Set Authentication
        if(USE_CREDENTIALS) {
            Credentials credentials = new UsernamePasswordCredentials(LOGIN, PWD); 
            CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
            credentialsProvider.setCredentials(AuthScope.ANY, credentials);
            httpClient.setCredentialsProvider(credentialsProvider);
        }
        else if(USE_TICKET) {
            URL = URL + "?alf_ticket=" + TICKET;
        }
       
        // Use Post
        HttpPost request = new HttpPost(URL);

        // Read Server Response
        HttpResponse response = httpClient.execute(request); 
      
       // Checking response…
       if( response.getStatusLine().getStatusCode() == 200 ) {
           String json = getJSon(response.getEntity().getContent());
           System.out.println("JSON received: " + json);
       }
       else {
           System.err.println("Upload Failed: \n"
               + response.getStatusLine().getStatusCode() + " : " + response.getStatusLine().getReasonPhrase() + "\n"
               + getJSon(response.getEntity().getContent()) );
       }

But I get the same error.

Any idea about why I get that error and how I can solve it ?

Thx 4 hlp !
2 REPLIES 2

mrogers
Star Contributor
Star Contributor
Look on the server and see if there is an error in the alfresco.log file.   That may give you a clue as to what you are doing wrong.

dryok
Champ in-the-making
Champ in-the-making
Look on the server and see if there is an error in the alfresco.log file.   That may give you a clue as to what you are doing wrong.
Thx for the fast reply, but is not errors in the log file or console.

EDIT: MORE INFORMATION

When I use other services of RestApi all works fine, as login (by post) and the full response of error is:

500 : Error Interno del Servidor
{    "status" :   {    "code" : 500,    "name" : "Internal Error",    "description" : "An error inside the HTTP server which prevented it from fulfilling the request."  },      "message" : "Unexpected error occured during upload of new content.",    "exception" : "",    "callstack" :   [           ],    "server" : "Alfresco Community v3.2.0 (r2 2440) schema 3.300",  "time" : "30-ene-2010 17:51:05"}