-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React Native Issue uploading smaller files #306
Comments
We have changed to using the direct upload API for smaller file uploads (smaller than 100mb). We now need a way to upload files greater than 100mb. I have tried to use the Javascript library above but that now also appears to be blowing up in my ReactNative app. I have tried changing the maxConcurrentRequests to 1 thinking it might be a resource issue but that still hasn't fixed it. |
I am now getting file size mismatch when calling complete on the multipart upload. Not sure if this is something to do with the way I do the chunking in my ReactNative (Expo) app.
|
I'm not quite understand why you're doing your own implementation? Until we release a fixed version, you can import needed methods directly and use react-native file-like object ( Example: import defaultSettings from '@uploadcare/upload-client/lib/defaultSettings';
import uploadFile from '@uploadcare/upload-client/lib/uploadFile';
import uploadMultipart from '@uploadcare/upload-client/lib/uploadFile/uploadMultipart';
const uri = image.uri;
const resp = await fetch(uri);
const blob = await resp.blob();
const name = 'filename.ext';
const size = blob.size
const type = blob.type
const populateOptionsWithSettings = (options) => ({
...defaultSettings,
...options,
});
const options = { publicKey: 'demopublickey' }
const asset = { size, name, type, uri }
uploadFile(asset, populateOptionsWithSettings(options));
uploadMultipart(asset, populateOptionsWithSettings(options)) |
@nd0ut using that approach the call to getChuck within uploadMultipart doesn't like the file. This is the error I get using your example above.
|
@nd0ut trying your approach, passing in the blob and extra options seems to do what I want but I get issues like a mentioned previously. The whole reason for me trying my own approach was that it seems to be hit and miss and the app just completely crashes during an upload, doesn't drop in the the catch block just dumps out. Like I said above I didn't know if it was something to do with the concurrent requests, this is why I get a failure without anyway to catch the error.
|
Yep, I was wrong, uploadMultipart requires a Blob, sorry. I was able to reproduce both problems with size mismatch and crashes on large files, I'll take a look into it. Thanks! |
I'm glad you were able to reproduce the errors and it wasn't me doing something wrong my end. I have been banging my head against this for a while now! Any timescales when you think the fix can be rolled out? We are looking at getting this in the app asap as we were doing our own transcoding and uploading on our own server but it makes no sense for us to do it. We are better offloading this onto your service. |
@paulsizer Now to the good stuff. I ran your code and it seems that
|
Ha, I turned off the queue and retry mechanics and the crashes are gone. I'm close to a clue. |
It will not crash if you set |
@nd0ut What would be the best way to do this? Is there a way to set that on the options for that you pass into populateOptionsWithSettings? |
Catched it. When any of sliced blobs get collected, react-native will deallocate the whole blob, which is leading to the app crash. @paulsizer for now you can temporarily set |
@nd0ut Excellent thanks Alex, I'll give it a go! |
@nd0ut Hi Alex I tried the following but it seems to be even worse now! Crashes every single time, pretty much instantly now.
|
@paulsizer I'll release a new version soon, it should work. #314 |
@paulsizer Does version 1.1.3 work as expected? |
@nd0ut Sorry it's taken a while to get back to you. Myself and @stevesizer have tried to use the uploadFile method in the following ways:
But both result in the following: TypeError: File uploading from "[object Object]" is not supported. I have also tried to use the multipartUpload and I am still having issues...
The above seemed to work the first time round. Tried it again with the same file and then it crashed as it has done in the past without any error. I then remembered you mentioned about setting the maxConcurrentRequests. So I tried the following.
As before this just dumps straight out no errors, just a complete crash... Definitely using the new version 1.1.3
|
@paulsizer
Are you trying to upload the same blob or a new one a second time? React-native deallocates blob from the memory after upload complete, so you can't use the same blob after uploading and need to recreate it from uri again. |
@nd0ut I am creating a new one again from uri |
@paulsizer Is it the same uri, or a new one? Strange thing. Probably, fresh blobs are created by reference, not by value and react-native clears memory that blob and uri pointing on. I was tested double uploads using I'll dig into it. |
Yeah it was the same uri
…On Wed, 31 Mar 2021 at 15:01, Aleksandr Grenishin ***@***.***> wrote:
@paulsizer <https://github.com/paulsizer> Is it the same uri, or a new
one?
Strange thing. Probably, fresh blobs are created by reference, not by
value and react-native clears memory that blob and uri pointing on.
I was tested double uploads using expo-asset's fromModule with no errors.
But I don't know how it's works, seems that it creates new files in memory
every time.
I'll dig into it.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#306 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AARFCTMR2AMVHU3AZ623NALTGMTNHANCNFSM4YXXYMIA>
.
|
@paulsizer According to this comment, Example: let blobCopy = new Blob([blob])
await client.uploadFile(blobCopy, options)
... Please, check it on your end and I'll add this workaround to the upload-client codebase if it would work. |
Hey @paulsizer, did this workaround work? |
Hey sorry @nd0ut I have been super busy trying to get other pieces of the app out. I have just tested what you suggested and it dumped me straight out. No errors just a fatal crash. |
Anymore news on this? Some clients are starting to get frustrated.
… On 11 May 2021, at 12:26, Paul ***@***.***> wrote:
Hey sorry @nd0ut <https://github.com/nd0ut> I have been super busy trying to get other pieces of the app out.
I have just tested what you suggested and it dumped me straight out. No errors just a fatal crash.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#306 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AARHUFU7RDJO4BDJNPDHPTTTNEH4ZANCNFSM4YXXYMIA>.
|
@paulsizer could you provide a minimal snippet? I can't reproduce it :( |
@nd0ut I have been testing this morning and everything appears to be working for the larger files now if we set maxConcurrentRequests = 1 We are doing the following to call the different APIs depending on the size, as there is a size limit for multipart uploads
This works as expected on iOS but on Android for images that are under the 10Mb threshold we get an error that seems to come from using the uploadFile method.
We do not get this error on iOS. |
@paulsizer Try to use react-native-url-polyfill on Android to create URL for blobs. |
I have added this library to my ReactNative project. It works great for larger file sizes but trying to use it for smaller files doesn't seem to be working.
I get the following error when trying to upload smaller files:
UploadClientError: [400] Request does not contain files.
This works fine with 3-minute videos, I have no issues with it at all.
This is the code I am using to upload the files:
Expo CLI 4.1.4 environment info:
System:
OS: macOS 10.15.7
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 12.16.3 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.4 - /usr/local/bin/npm
SDKs:
iOS SDK:
Platforms: iOS 14.4, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
IDEs:
Android Studio: 3.6 AI-192.7142.36.36.6392135
Xcode: 12.4/12D4e - /usr/bin/xcodebuild
npmPackages:
expo: ^40.0.1 => 40.0.1
react: 16.13.1 => 16.13.1
react-dom: 16.13.1 => 16.13.1
react-native: https://github.com/expo/react-native/archive/sdk-40.0.1.tar.gz => 0.63.2
react-native-web: ~0.13.12 => 0.13.14
npmGlobalPackages:
expo-cli: 4.1.4
Expo Workflow: managed
The text was updated successfully, but these errors were encountered: