[Webkit-unassigned] [Bug 187461] Fetch using FormData with file doesn't go through Service Worker

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Jul 24 08:31:51 PDT 2018


https://bugs.webkit.org/show_bug.cgi?id=187461

--- Comment #4 from nyro <cedric at nyrodev.com> ---
Youenn, following your recommandation, I ended up with the following:

#####################
formData.delete('file');

// get it as blob adn readd it as regular post field
// NB: File has to be recreated on server side using _files[file][name] and _files[file][data] to work as it was a regular file upload
var file = form.querySelector('input[type="file"]').files[0];

formData.append('_files[file][name]', file.name);

var reader = new FileReader();
reader.onload = function (e) {
    formData.append('_files[file][data]', e.target.result);

    doFetch(id, form, formData);
};
reader.readAsDataURL(file);
#####################

Which works, the request goes through the service Worker.

On server side, it becomes a little tricky regarding the language choosen, but I mentionned all the necessearry regarding PHP, the one I'm using.

I didn't implemented it yet on my production PWA, but I'll do it soon and come back here if I found out more gotcha.

In the mean time, I hope this will be fixed soon on Safari in order to remove all this code ;)

All the updated code and exemple have been updated on my demo page:
https://bugs.nyro.com/safariFileUpload/

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20180724/2c14fd72/attachment-0001.html>


More information about the webkit-unassigned mailing list