-
Notifications
You must be signed in to change notification settings - Fork 29
Uploading results as empty file without mime type without errors #13
Comments
Same problem here. Looking for a workaround, will update if I find something. |
Problem is going from fetch polyfill package and there are PR that not merged yet
|
Thank you so much for that! |
I'm having this issue as well when using the ios simulator. I checked in node_modules/whatwg-fetch and it has that change that the PR added. Help! |
I think the problem is that this worked for me. function urlToBlob(url) {
return new Promise((resolve, reject) => {
var xhr = new XMLHttpRequest();
xhr.onerror = reject;
xhr.onreadystatechange = () => {
if (xhr.readyState === 4) {
resolve(xhr.response);
}
};
xhr.open('GET', url);
xhr.responseType = 'blob'; // convert type
xhr.send();
})
}
|
@yonahforst thanks!! |
You the man @yonahforst |
AWESOME @yonahforst !!!!!! Just completely saved me, thank you! 🎖 |
Hey guys ... this is a huge issue for me. I am now having an issue with @yonahforst 's function... for some reason the func switching views in my app after PUT. When I use the old fetch the problem doesn't happen (alas no blob either)... is anyone else getting this with the function above? Would rolling back SDKs fix this entire issue?? |
@evilandfox can you explain a bit more how this fix works? |
@barrylachapelle That's very simple. It is just the original code for overwriting global fetch function with additional
line of fix. And |
@jlsilva10 I used the solution above directly in my code. Use /**
* Get file blob using local file URI
*/
const blob = await uriToBlob(uri);
const options = {
method: "PUT",
body: blob,
headers: {
"Content-Type": "image/jpeg",
},
};
/**
* Upload blob to your API endpoint
*/
return fetch("your-api/some-endpoint", options); |
Thanks! Worked like a charm ;) |
Use that urlToBlob, and return this: Promise { |
That returns a promise, you need to await for it. |
This has to be in the sample code. It took 2 days to figure out the issue. |
Can you tell what file should we edit, please? |
I guess this one |
I cannot patch the whatwg-fetch.js correctly I am getting |
@EnginYilmaz just use yonahforst code above |
In my situation I am not using GET or PUT just URL for the fetch function for example
|
@EnginYilmaz same thing, just use the code from yonahforst and do |
@jrnk I tried but function never finishes loading and getting warning message
|
@EnginYilmaz how are you using it ? please post your code this should work =
|
I am getting Network request failed 504:29 error message but not using local or remote image so no image URL. I am using it as #13 (comment) |
I think it is better not to use fetch anywhere I will have to change all the code to XMLHttpRequest on each scene. I have fetch function nearly on 20 pages in total! I hope this will help anyone consider to use fetch in their project. |
@EnginYilmaz surely you can just write a fetch function and call it in your 20 pages, it will be a simple find and search ? |
@farzd I have lots of codes like
What will happen to after .then I need to write them from scratch. |
Besides, I afroid getting same error message after getting away from fetch |
@EnginYilmaz I think you're having a different issue, this issue is about uploading an image with the fetch module. You also dont have a catch in your fetch, use a catch and post the error you're getting |
Does anyone know if fetch is already fixed in sdk32? because XMLHttpRequest() is unfortunately very slow. |
Finding and reading this thread after at least 60 minutes of wasted work. Thanks so much for the help! |
Anyone else having trouble getting the blob of a large file, e.g. video file that is over 500 MB in size? |
Have anyone same problem?
The text was updated successfully, but these errors were encountered: