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

Support for Data Blobs? #16034

Closed
austinksmith opened this issue Sep 20, 2017 · 25 comments
Closed

Support for Data Blobs? #16034

austinksmith opened this issue Sep 20, 2017 · 25 comments
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.

Comments

@austinksmith
Copy link

austinksmith commented Sep 20, 2017

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

All

Steps to Reproduce

Create a React Native application and attempt to create a data blob, error is created saying a "Blob can only be created from another Blob".

Expected Behavior

A data blob is created the same as it works for all other JavaScript execution environments

Actual Behavior

Support for data blobs appears broken with an error message of "Data blob can only be created from another blob"

Reproducible Demo

You may make use of my library Hamsters.js to see this in action, simply follow the instructions to import the library into a React Native application. A user of my library has reported this bug to me and I would really like to see support for my library brought back as it relies on data blob creation for efficient operation, the alternatives are bad for performance.

austinksmith/Hamsters.js#40

@austinksmith
Copy link
Author

Any response on this? Curious on how to create new data blobs in RN

@shoebmogal
Copy link

I am experiencing the same issue. Curious to know the work around.

@edi
Copy link

edi commented Oct 3, 2017

Same thing here. Was just trying to upload some files with Firebase Storage in a react native app, used RNFS to get the actual file, all works fine, but when I actually try and upload it, this errors pops up, and I guess Firebase uses this type of blob ( out of base64 strings ) as well ..

@bitcoinvsalts
Copy link

same thing in here, it used to work with the previous react native version.

@serhiipalash
Copy link

@Eduardjs I have the same error. Did you find a solution?

@edi
Copy link

edi commented Oct 17, 2017

Hello gents, and Yes. I have worked around the lack of support for Blob in RN by using RNFetchBlob ( react-native-fetch-blob ). Getting assets-library data via react-native-camera-roll-picker

const imageRef = storage
	.ref( user.objectId )
	.child( `messages/${conversation.roomId}/${Date.now()}.jpg` )

Blob.build( RNFetchBlob.wrap( URI_FROM_PHOTO_PICKER ), { type: 'application/octet-stream' })
	.then( blob => {

		imageRef
			.put( blob, { contentType: 'application/octet-stream' })
			.then( () => {
				blob.close()
				return imageRef.getDownloadURL()
			})

	})

Hope it helps :)

@serhiipalash
Copy link

serhiipalash commented Oct 17, 2017

@Eduardjs thanks for your help! Unfortunately, this does not work in my situation. We use Expo and I can not add response-native-fetch-blob to the project.

I guess the only thing we can do is use some cloud function that will get base64 string, convert it into byteArray and store in Firebase.

@edi
Copy link

edi commented Oct 17, 2017

@serhiipalash Hello. Sorry to hear that. Firebase also supports putString ( base64 ) but it can't create a blob inside RN enviroment since it's actually developed for web browsers.

@bitcoinvsalts
Copy link

also using expo and still no solution

this issue is blocking us to release our app to production

@serhiipalash
Copy link

@Eduardjs Hi! I tried putString last week and it does not work.

@serhiipalash
Copy link

this issue is blocking us to release our app to production

+1

@serhiipalash
Copy link

also using expo and still no solution

I will write here solution with cloud function if it will work.

@edi
Copy link

edi commented Oct 17, 2017 via email

@serhiipalash
Copy link

serhiipalash commented Oct 17, 2017

As for waiting for an improvement, don’t get your hopes up

😄

The speed of adding new features in RN is very slow compared to the normal React world. It was a big surprise for me when I started working with RN.

@badenai
Copy link

badenai commented Oct 18, 2017

Getting same issue on a 64-Bit Android emulator. Using 32-Bit now an everything works as expected.

@dantman
Copy link
Contributor

dantman commented Oct 19, 2017

@Eduardjs thanks for your help! Unfortunately, this does not work in my situation. We use Expo and I can not add response-native-fetch-blob to the project.

RNFB is also not really an option for many projects even when they're not using Expo.

That library has some critical issues regarding how it handles things from document providers on Android:
wkh237/react-native-fetch-blob#525

@edi
Copy link

edi commented Oct 19, 2017 via email

@kelset
Copy link
Contributor

kelset commented Oct 19, 2017

As far as I know there's an open PR to add this functionality: #11573

@wcandillon
Copy link
Contributor

@serhiipalash did you end writing that cloud function?

@karimraoudy
Copy link

@serhiipalash did you end writing that cloud function? i'm realy stuck .Thank You

@wcandillon
Copy link
Contributor

@serhiipalash @karimraoudy I wrote a cloud function for this: https://medium.com/@wcandillon/uploading-images-to-firebase-with-expo-a913c9f8e98d

@karimraoudy
Copy link

@wcandillon I did saw your post but didn't understand how to implant in my code. thank you for your reply

@TizioFittizio
Copy link

I'm experiencing this too, tried base64, base64url and blob with no luck

@pablo-albaladejo
Copy link

@wcandillon Thank you very much for sharing your solutions. Worked like a charm for me!

@react-native-bot
Copy link
Collaborator

Thanks for posting this! It looks like you may not be using the latest version of React Native, v0.53.0, released on January 2018. Can you make sure this issue can still be reproduced in the latest version?

I am going to close this, but please feel free to open a new issue if you are able to confirm that this is still a problem in v0.53.0 or newer.

How to ContributeWhat to Expect from Maintainers

@react-native-bot react-native-bot added Ran Commands One of our bots successfully processed a command. Stale There has been a lack of activity on this issue and it may be closed soon. labels Feb 24, 2018
@stale stale bot removed the Stale There has been a lack of activity on this issue and it may be closed soon. label Feb 24, 2018
@facebook facebook locked as resolved and limited conversation to collaborators May 27, 2019
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label May 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Ran Commands One of our bots successfully processed a command. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests