[Seaside] Re: Rest - Ajax request - build file
Sebastien Audier
sebastien.audier at gmail.com
Fri Mar 20 00:42:59 UTC 2015
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>:
>
> 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;
> 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/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20150319/7c697faf/attachment-0001.htm
More information about the seaside
mailing list