[Seaside] Re: Rest - Ajax request - build file

Bob Arning arning315 at comcast.net
Fri Mar 20 01:02:00 UTC 2015


Not really sure I understand the question, but it sounds like you would 
need to include some sort of position information in each POST. That way 
the receiving end knows where in the file to put the data.

On 3/19/15 8:42 PM, Sebastien Audier wrote:
> Okay, I dropped the idea of cut the file.
>
> One solution (not tested yet): ZnConstants maximumEntitySize: 
> 104857600 (100 * 1024 * 1024) in order to increase the size of 
> incoming entities to 100 M for example.
>
> But, if we find one solution for the other case, we could upload file 
> faster.
>
> Happy smalltalk ;)
>
> 2015-03-12 15:21 GMT-10:00 Sebastien Audier 
> <sebastien.audier at gmail.com <mailto:sebastien.audier at gmail.com>>:
>
>
>     Hi all,
>
>     I work on pharo 2.0 and seaside-REST with ZincServer.
>
>     I need to rebuild a file which is uploaded by POST requests
>     through Seaside-REST but I don't really use WASession.
>
>     On javascript layer, I cut the file with this function:
>
>     document.querySelector('input[type="file"]').addEventListener('change',  function(e)  {
>        var name =this.files.name  <http://this.files.name>;
>        var  blob=  this.files[0];
>
>        const  BYTES_PER_CHUNK=  1024  *  1024;  // 1MB chunk sizes.
>        const  SIZE=  blob.size;
>
>        var  start=  0;
>        var  end  =  BYTES_PER_CHUNK;
>
>        while(start<  SIZE)  {
>          upload(name,blob.slice(start,  end));
>
>          start=  end;
>          end  =  start+  BYTES_PER_CHUNK;
>        }
>     },  false);
>
>     And I send datas with this function:
>
>     function  upload(aFileName,  files)  {
>        var  formData=  new  *FormData*();
>
>        for  (var  i=  0,  file;  file=  files[i];  ++i)  {
>          *formData.append(aFileName,  file);*
>        }
>
>        var  xhr=  new  XMLHttpRequest();
>        xhr.open('POST',  '/myPath',  true);
>        xhr.onload=  function(e)  {  ...  };
>
>        xhr.send(*formData*);   // multipart/form-data
>     }
>
>
>     I have a POST method on my handler, but I receive multiple requests.
>     On this way, I don't have access to the requestContext in order to
>     get the WAFile in request.
>     If I don't cut the file, it works and I can store on disk. But not
>     in the other case.
>
>     Of course, my goal is to store the file on disk correctly.
>
>     So,
>     How to get file content of each request ?
>     How  to rebuild and store the file correctly if the requests
>     aren't ordored ?
>
>     Any help ?
>
>     Thank's a lot.
>
>
>     -- 
>     Sébastien AUDIER
>
>
>     <http://www.objectfusion.fr/>
>
>
>
>
> -- 
> Sébastien AUDIER
>
>
> <http://www.objectfusion.fr/>
>
>
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20150319/240e854d/attachment.htm


More information about the seaside mailing list