question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fetching blobs from filesystem results in blob-size: 0

See original GitHub issue

Environment

React Native Environment Info:
    System:
      OS: macOS High Sierra 10.13.4
      CPU: x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
      Memory: 769.02 MB / 16.00 GB
      Shell: 2.7.1 - /usr/local/bin/fish
    Binaries:
      Node: 8.9.3 - ~/.nvm/versions/node/v8.9.3/bin/node
      Yarn: 1.7.0 - /usr/local/bin/yarn
      npm: 6.1.0 - ~/.nvm/versions/node/v8.9.3/bin/npm
      Watchman: 4.9.1 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 11.4, macOS 10.13, tvOS 11.4, watchOS 4.3
    IDEs:
      Android Studio: 3.0 AI-171.4443003
      Xcode: 9.4/9F1027a - /usr/bin/xcodebuild
    npmPackages:
      react: 16.4.1 => 16.4.1
      react-native: 0.56.0-rc => 0.56.0-rc

Description

After upgrading from react native 0.55.4 (which introduced blob fetching) to react native 0.56.0-rc I experience issues with blob fetching on iOS (android not tested). When fetching an image/video from filesystem and building a blob from it, the blob-size is 0.

const mediaResponse = await fetch('file:///var/mobile/Containers/Data/Application/.../Library/CachesCamera/....mov');

// convert response to blob
const mediaBlob = await mediaResponse.blob();

console.log(mediaBlob.size) 
// 0

I am aware of this react-native-blob-test repo but these tests doesn’t seem to fail on size === 0 since an && operator is used instead of an || operator : https://github.com/expo/react-native-blob-test/blob/c0dbd66f4e2a193a5031c52c9b49ea2a6b4419ed/index.common.js#L291

Steps to Reproduce

https://github.com/expo/react-native-blob-test/blob/master/index.common.js#L134

Expected Behavior

Since the image/video exists (i can save it via CameraRoll.saveToCameraRoll) the resulting blob should have a valid size (positive number).

Actual Behavior

The blob has a size of 0.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:9
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
reime005commented, Nov 1, 2018

This issue is still present in the latest React Native release (0.57.4)

2reactions
gjdycuscommented, Jun 27, 2018

Does anyone know of any workarounds for this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fetch blob from URL and write to file - node.js - Stack Overflow
Note that I'm logging blob. size before calling writeFile . blob. size shows the correct size, so fetch seems to be successful.
Read more >
Blob JavaScript API - JavaScripture
Blobs are immutable objects that represent raw data. File is a derivation of Blob that represents data from the file system. Use FileReader...
Read more >
List blobs with .NET - Azure Storage - Microsoft Learn
When you list blobs from your code, you can specify a number of options to manage how results are returned from Azure Storage....
Read more >
Blob.size - Web APIs - MDN Web Docs
The Blob interface's size property returns the size of the Blob or File in bytes.
Read more >
File API - W3C
getElementById ( 'file' ). files [ 0 ]; if ( file ){ getAsText ( file ); ... Scenarios exist when the Blob constructor...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found