react-firebase-file-uploader icon indicating copy to clipboard operation
react-firebase-file-uploader copied to clipboard

I have an Uncaught exception in handleUploadSuccess

Open aelhirach opened this issue 4 years ago • 13 comments

Uncaught (in promise) TypeError: Cannot read property 'name' of null at Observer.complete (index.js:150) at async.ts:27

Screenshot 2020-12-11 at 14 59 40

aelhirach avatar Dec 11 '20 14:12 aelhirach

I am experiencing the same issue

jasony4 avatar Dec 13 '20 18:12 jasony4

Is it error getting metadata? Check this: #55

qnxdev avatar Dec 14 '20 13:12 qnxdev

I found the source of the issue, it is located in handleUploadSuccess when this function is callback with a task.metadata.name. I fixed it by adding a metadata with name field.

aelhirach avatar Dec 14 '20 14:12 aelhirach

image

I cant say what the problem but i cant seem to make this bug fixed.

i have tried task.snapshot.ref and it did not work - it says undefined have also tried task.metadata.name and it did not work - it says undefined

have also tried adding this script

var name = storageRef.child(filenameToUse).getMetadata().then(function (metadata) {
return metadata.name;
});

and the .then is never triggered

running version - "react-firebase-file-uploader": "^2.4.2"

okechukwu0127 avatar Dec 18 '20 07:12 okechukwu0127

having this issue as well

samirsd avatar Dec 23 '20 17:12 samirsd

Refer #55 There is ein solution

qnxdev avatar Dec 26 '20 17:12 qnxdev

I fixed it by adding a metadata with name field.

Can you explain how you did that?

EDIT: Nvm, solved it!

johnzzon avatar Jan 09 '21 20:01 johnzzon

I fixed it by adding a metadata with name field.

Can you explain how you did that?

EDIT: Nvm, solved it!

how did you do it please

1stmuse avatar Jan 13 '21 01:01 1stmuse

Different solutions work for different versions of firebase.

qnxdev avatar Jan 13 '21 09:01 qnxdev

Different solutions work for different versions of firebase.

i did a stupid thing but got a solution, i passed metadata to the fileuploader, then on onuploadSuccess i used the second callback which is the task to get the filename because the first callback was just returning the name i specified in the metadata Screenshot from 2021-01-13 12-12-09

1stmuse avatar Jan 13 '21 11:01 1stmuse

I have the same issue, was anybody able to fix this and can explain exactly how they did it? I tried everything suggested above with no luck.

cmarabate avatar Jan 15 '21 18:01 cmarabate

Here is my version that work for me.

lib/index.js

task.on('state_changed', function (snapshot) { return onProgress && onProgress(Math.round(100 * snapshot.bytesTransferred / snapshot.totalBytes), task); }, function (error) { return onUploadError && onUploadError(error, task); }, function () { _this2.removeTask(task); return onUploadSuccess && onUploadSuccess(filenameToUse, task); }); _this2.uploadTasks.push(task); });

I change 'task.snapshot.metadata.name' to 'filenameToUse'

toreal avatar Feb 03 '21 11:02 toreal

Here is my version that work for me.

lib/index.js

task.on('state_changed', function (snapshot) { return onProgress && onProgress(Math.round(100 * snapshot.bytesTransferred / snapshot.totalBytes), task); }, function (error) { return onUploadError && onUploadError(error, task); }, function () { _this2.removeTask(task); return onUploadSuccess && onUploadSuccess(filenameToUse, task); }); _this2.uploadTasks.push(task); });

I change 'task.snapshot.metadata.name' to 'filenameToUse'

Great, it works!!! Thanks

GustavoMelgarF avatar Feb 06 '21 18:02 GustavoMelgarF