Currently I'm working on a page that allows users to upload a file to Firebase Storage. When opening the site through Google Chrome on Android and selecting a file for upload from a standard HTML file input, it uses Android's native file chooser.
In most cases, a user would choose a file stored locally on the device, but the file chooser also shows their Google Drive files and a user currently isn't prevented from selecting one of those files. The file is returned as a File object in Javascript, but when the upload to Firebase Storage is attempted it throws the error: "net::ERR_UPLOAD_FILE_CHANGED" and eventually exceeds it's retry limit.
To prevent confusion for the user, I'd like to prevent the user from selecting a Google Drive file in Android's file chooser, or at the very least recognize that it can't be uploaded and warn the user.
I considered checking the File object returned by the input element, but there isn't any indication to tell a local file from a Google Drive file.
<input type="file" id="upload_input" class="hide"/>
$("#upload_input").change(function(e) {
if (!e.target.files) {
return;
}
const file = e.target.files[0];
uploadFile(file);
});
uploadFile(file) {
...
const storageRef = firebase.storage().ref();
const fileRef = storageRef.child(`${userID}/uploads/${file.name}`);
const uploadTask = fileRef.put(file);
...
}