Code Monkey home page Code Monkey logo

Comments (5)

BraveEvidence avatar BraveEvidence commented on July 24, 2024

Here is my further debugging

this is my uri file:///Users/transformhub/Library/Developer/CoreSimulator/Devices/6B91F341-3D64-4464-89EB-95A9071CCA3F/data/Containers/Data/Application/1CC49EE3-60ED-4AED-912B-FDA7FB3B1284/tmp/CA4139AE-C50F-4420-9EDB-95EFA6910B6D.jpg

this is my type image/jpg

const blobData = await ReactNativeBlobUtil.fetch('GET', uri!);
const blob = await blobData.blob(type!, 1024);

But I get error saying
Simulator Screenshot - iPhone Xs - 2024-02-19 at 12 36 17

u

from react-native-blob-util.

emclab avatar emclab commented on July 24, 2024

facing exactly the same problem. Tried to readFile the image into base64 first but hasn't figured out how to convert base64 to blob. React Native 0.70. ReactNativeBlobUtil 0.19.6

Tried the code below but the response doesn't have a blob

const response = await ReactNativeBlobUtil
        .config({ fileCache: true })
        .fetch('GET', `data:${_contentType};base64,${_base64}`);  //<< _base64 is the image data string in base64. _contentType is image/jpeg.

from react-native-blob-util.

emclab avatar emclab commented on July 24, 2024

Found a closed issue here: #297

Not sure if the solution (formData and XMLHttprequest by @RonRadtke) provided is working here as well.

from react-native-blob-util.

emclab avatar emclab commented on July 24, 2024

Here is the conversion working on my RN 0.70.x:

import {decode, encode} from 'base-64';  //<<==yarn add base-64 if not available
// Convert base64 to blob 
    function base64ToUint8Array(base64) {
      try {      
        const binaryString = decode(base64); // Decode base64
        const len = binaryString.length;
        const bytes = new Uint8Array(len);
        for (let i = 0; i < len; i++) {
          bytes[i] = binaryString.charCodeAt(i);
        }
        return bytes;  //<<==bytes is the blob which is to be used directly in fetch PUT
      } catch (err) {
        return null;
      };
    }

from react-native-blob-util.

BraveEvidence avatar BraveEvidence commented on July 24, 2024

@emclab Genius. Thank you

from react-native-blob-util.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.