Skip to content
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

Add react-native support #289

Closed
retyui opened this issue Aug 18, 2020 · 1 comment
Closed

Add react-native support #289

retyui opened this issue Aug 18, 2020 · 1 comment
Assignees

Comments

@retyui
Copy link

retyui commented Aug 18, 2020

If you try to use this client to upload a file you will see the next error:

https://github.com/uploadcare/uploadcare-upload-client/blob/9abd0b059ce90e20e044d471625d55fa5e28527d/src/uploadFile/index.ts#L168

So, I have to use a hack to upload file

import defaultSettings from '@uploadcare/upload-client/lib/defaultSettings';
import upload from '@uploadcare/upload-client/lib/uploadFile';

const populateOptionsWithSettings = (options) => ({
  ...defaultSettings,
  publicKey: 'XXXXX',
  ...options,
});

export const uploadFile = ({ size, name, type, uri }, options) =>
  upload({ name, size, type, uri }, populateOptionsWithSettings(options));
@nd0ut
Copy link
Member

nd0ut commented Mar 15, 2021

Hey @retyui
Thanks for report.

With such input file format, we can't slice it into chunks to upload multipart. It's better to convert it to the Blob like this:

const resp = await fetch(uri);
const blob = await resp.blob();

But for now, direct uploads does not support react-native Blobs. It will be fixed by #307

@nd0ut nd0ut closed this as completed Mar 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants