Coming from https://github.com/angular/angularfire2/issues/1803. I'm using angularfire2 and firebase storage. When service worker is enabled, the upload is fail on iOS safari saying
Multipart body does not contain 2 or 3 parts.

Create simple app with angular cli and default service worker configuration. While you upload a file, for some service worker issues the upload fails and this only happens on iOS safari with SW enabled.
https://stackblitz.com/fork/firebase-issue-sandbox
I cannot provide a pure JS code example since my code is Angular. But i may try to create angular sample
startUpload() {
const base64strOrj: string = ....
const base64str = base64strOrj.replace('data:image/jpeg;base64,', '');
const metadata = {
...
};
const filePath = ...
const fileRef = this.storage.ref(filePath);
const task = fileRef.putString(base64str, 'base64', metadata);
this.showUpload = true;
// observe percentage changes
task.percentageChanges().pipe(tap(perc => {
if (perc === 100) {
...
}
})).subscribe();
// get notified when the download URL is available
task.snapshotChanges().pipe(
finalize(() => fileRef.getDownloadURL().subscribe(url => {
...
}))
)
.subscribe();
}
Same issue. Did you find a workaround @arikanorh?
I'm having this same issue.
Same here
Any luck/workaround this ?
We are having the same issue, this seems like a real bug
im having same issue, Safari for iOS 12
I have this bug too, is anyone working on this ?
found a solution! I was using ngsw and on safari it break image uplaods.. see issue here
using a replace-in-file from npm
I run this after my build.
It excludes the firebase API from service worker caching...
const replace = require('replace-in-file');
const options = {
files: 'dist/browser/ngsw-worker.js',
from: `onFetch(event) {`,
to: `onFetch(event) {
if (event.request.url.indexOf('firebasestorage.googleapis.com') !== -1) { return; }`,
};
replace(options)
.then(changes => {
console.log('Modified files:', changes.join(', '));
})
.catch(error => {
console.error('Error occurred:', error);
});
i used the solution @koraysels posted, but just added
if (event.request.url.indexOf('firebasestorage.googleapis.com') !== -1) { return; }
to the first line of my fetch event listener directly.
Was this ever solved? I'm having the same issue on Safari.
Same issue still
For those using AngularFire2, consider this workaround.
Most helpful comment
found a solution! I was using ngsw and on safari it break image uplaods.. see issue here
using a
replace-in-filefrom npmI run this after my build.
It excludes the firebase API from service worker caching...