Code Monkey home page Code Monkey logo

react-native-blob-util's People

Contributors

adbl avatar alpha0010 avatar atlanteh avatar austinried avatar avmoroz avatar bcpclone avatar brainbicycle avatar cipolleschi avatar cortinico avatar cristianocca avatar doomsower avatar eleretic avatar ericmorgan1 avatar felipecsl avatar ggilles avatar gla5001 avatar ihavenoface5 avatar jbrodriguez avatar kdpadhiyar avatar lionesstester avatar lll000111 avatar mihailchugunov avatar mjmasn avatar mmathewstableau avatar onlyling avatar ronradtke avatar smartt avatar traviskn avatar tszheichoi avatar wkh237 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

react-native-blob-util's Issues

Failed to find configured root that contains /data/data/com.android.providers.downloads/cache/filename.pdf

Failed to find configured root that contains /data/data/com.android.providers.downloads/cache/filename.pdf
This error occurs when I try to open a pdf I downloaded using
android.actionViewIntent(res.path(), 'application/pdf')
The file itself saves successfully to the path I presume, but I have no way to check
Also when is the ability to save to MediaStore.Download will come?
Any help would be appreciated, thanks!

Package not visible in Android Studio

I'm not sure what's wrong with the build.gradle file of this project, but I haven't been able to make this library appear in Android Studio.

Any ideas of what is missing? Here's a sample file I have used for another custom library that correctly shows in Android Studio.

// android/build.gradle

// based on:
//
// https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle

def DEFAULT_COMPILE_SDK_VERSION = 29
def DEFAULT_BUILD_TOOLS_VERSION = '29.0.3'
def DEFAULT_MIN_SDK_VERSION = 16
def DEFAULT_TARGET_SDK_VERSION = 29

def safeExtGet(prop, fallback) {
    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

apply plugin: 'com.android.library'
apply plugin: 'maven'

buildscript {
    // The Android Gradle plugin is only required when opening the android folder stand-alone.
    // This avoids unnecessary downloads and potential conflicts when the library is included as a
    // module dependency in an application project.
    // ref: https://docs.gradle.org/current/userguide/tutorial_using_tasks.html#sec:build_script_external_dependencies
    if (project == rootProject) {
        repositories {
            google()
            jcenter()
        }
        dependencies {
            classpath 'com.android.tools.build:gradle:4.1.0'
        }
    }
}

apply plugin: 'com.android.library'
apply plugin: 'maven'

android {
    compileSdkVersion safeExtGet('compileSdkVersion', DEFAULT_COMPILE_SDK_VERSION)
    buildToolsVersion safeExtGet('buildToolsVersion', DEFAULT_BUILD_TOOLS_VERSION)
    defaultConfig {
        minSdkVersion safeExtGet('minSdkVersion', DEFAULT_MIN_SDK_VERSION)
        targetSdkVersion safeExtGet('targetSdkVersion', DEFAULT_TARGET_SDK_VERSION)
        versionCode 1
        versionName "1.0"
    }
    lintOptions {
        abortOnError false
    }
}

repositories {
    // ref: https://www.baeldung.com/maven-local-repository
    mavenLocal()
    maven {
        // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
        url "$rootDir/../node_modules/react-native/android"
    }
    maven {
        // Android JSC is installed from npm
        url "$rootDir/../node_modules/jsc-android/dist"
    }
    google()
    jcenter()
}

dependencies {
    //noinspection GradleDynamicVersion
    implementation 'com.facebook.react:react-native:+'  // From node_modules
}

def configureReactNativePom(def pom) {
    def packageJson = new groovy.json.JsonSlurper().parseText(file('../package.json').text)

    pom.project {
        name packageJson.title
        artifactId packageJson.name
        version = packageJson.version
        group = "com.package.name"
        description packageJson.description
        url packageJson.repository.baseUrl

        licenses {
            license {
                name packageJson.license
                url packageJson.repository.baseUrl + '/blob/master/' + packageJson.licenseFilename
                distribution 'repo'
            }
        }

        developers {
            developer {
                id packageJson.author.username
                name packageJson.author.name
            }
        }
    }
}

afterEvaluate { project ->
    // some Gradle build hooks ref:
    // https://www.oreilly.com/library/view/gradle-beyond-the/9781449373801/ch03.html
    task androidJavadoc(type: Javadoc) {
        source = android.sourceSets.main.java.srcDirs
        classpath += files(android.bootClasspath)
        classpath += files(project.getConfigurations().getByName('compile').asList())
        include '**/*.java'
    }

    task androidJavadocJar(type: Jar, dependsOn: androidJavadoc) {
        classifier = 'javadoc'
        from androidJavadoc.destinationDir
    }

    task androidSourcesJar(type: Jar) {
        classifier = 'sources'
        from android.sourceSets.main.java.srcDirs
        include '**/*.java'
    }

    android.libraryVariants.all { variant ->
        def name = variant.name.capitalize()
        def javaCompileTask = variant.javaCompileProvider.get()

        task "jar${name}"(type: Jar, dependsOn: javaCompileTask) {
            from javaCompileTask.destinationDir
        }
    }

    artifacts {
        archives androidSourcesJar
        archives androidJavadocJar
    }

    task installArchives(type: Upload) {
        configuration = configurations.archives
        repositories.mavenDeployer {
            // Deploy to react-native-event-bridge/maven, ready to publish to npm
            repository url: "file://${projectDir}/../android/maven"
            configureReactNativePom pom
        }
    }
}

macos

Hi, the library will support react-native-macos soon?
Thanks

Crash on Android API 20 and below

Hi,

I noticed that after switching from rn-fetch-blob to this fork, my app started crashing on devices with android below API 21.
After some digging, I found out it is caused by requiring the latest Okhttp client on the Android dependencies list.

After removing the okhttp lines, it now works fine on all the devices I've tested on.
Is there a reason for having those dependencies explicitly declared, or can they be removed to regain full compatibility?

I know that RN v 0.64 increased the min API version to 21, but I'm still using RN 63 for some projects, and keeping it compatible with API 16+ is needed.

Thanks

MediaStore to use common downloads directory of android

Hi, thanks for maintaining this project. i have more of a query than a bug to report.
i'm using version 0.13.8 of this library and implementing scope storage related updates in my RN app.
Is there a way to download files directly to common download path for android, currently file download is happening in app specific internal storage, which might not be very intuitive for users in general.
Is there a plan to implement MediaStore API to make use of download path, or is there any other solution to do so?
Any help or suggestion is much appreciated.
Thanks.

The WRITE_EXTERNAL_STORAGE permission becomes useless in Android 10

react-native-blob-util: '0.13.2'
react-native: '0.61.2'

As of Nov 2020, all the android app published in the Google Play needs to set the targetSdkVersion to at least 29. The "android:maxSdkVersion" setting in the manifest makes the WRITE_EXTERNAL_STORAGE in the PermissionAndroid becomes useless in Android 10.
I have been taking a while to find that in my app mergedManifest. Finally, I added this:
tools:remove="android:maxSdkVersion"
to the permission WRITE_EXTERNAL_STORAGE.

I think it needs to be fixed. Meanwhile, and support Android 11 in future.

Wrong Dirs.MusicDir after upgrade from joltup

The Android directory constants are changed in #2. I think the change is wrong. Apps are still allowed to save files in root directories. For example, we let our app save their audio files in /storage/emulated/0/Musics. After migration to this package, the constants are changed and files are stored in private directories, which is wrong, at least for the purpose of our application.
I wonder if you can rollback the change, or introduce new constants for the legacy paths.
Thanks.

Missing android.support.FILE_PROVIDER_PATHS

I started getting this error when downloading a PDF document to download folder on android after upgrading to target SDK 30 (although I'm not sure this was the cause of the issue). I was able to fix the problem by adding this to the application section of my AndroidManifest.xml:

<provider android:name="com.ReactNativeBlobUtil.Utils.FileProvider" android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/provider_paths" /> </provider>

And this to android > src > main > res > xml > provider_paths.xml:

<?xml version="1.0" encoding="utf-8"?> <paths xmlns:android="http://schemas.android.com/apk/res/android"> <external-path name="external_files" path="." /> <files-path name="files-path" path="." /> <!-- Used to access into application data files --> <cache-path name="cache-path" path="." /> <!-- Used to access files in cache directory --> </paths>

I see these blocks are already defined in the blob-util library, I'm not sure why all the sudden my app was unable to pull it in from there. See:

https://github1s.com/RonRadtke/react-native-blob-util/blob/HEAD/android/src/main/AndroidManifest.xml

and:

https://github1s.com/RonRadtke/react-native-blob-util/blob/HEAD/android/src/main/res/xml/provider_paths.xml

I am using version 0.13.16 of react-native-blob-util and 0.64.1 of react-native.

androidJavadoc task failure causes build failures

Versions
React-native-blob-util version: 0.13.7
React native version: 0.63.3

Description
When we attempt to build our react native app which uses react-native-blob-util, this library's androidJavadoc task fails, which fails our build. We can modify the javadoc comments in the relevant file within this library to make the build succeed, but that isn't an option on any environment beyond our local environment, and really isn't a highly reasonable course of action in any case. In the meantime, we've locked our version to 0.13.6, which seems to work just fine.

Screen Shot 2021-06-02 at 10 30 52 AM

Download unsuccessful when I try download PDF file

I'm having touble downloading PDF files. When I try download small PDF file like 1 MB I haven't any problem, but when PDF size is like 5-10 MB Android Manager show ' Download unsuccessful' and catch error. My accessToken and URL are good because I was tried test this data in Postman and download was successful.

"react-native": "0.63.4",
"react-native-blob-util": "^0.13.16",

Error

[Error: Download manager failed to download from API Link . Status Code = 16]

I tried download files from this site https://www.learningcontainer.com/sample-pdf-files-for-testing/ but i have same problem (I changed URL in fetch)

The first file successful downloaded but second one (10MB) was failed. Maybe it's problem with timeout in Download Manager?

  const downloadPDF = async ({item}) => {
    if (Platform.OS === 'android') {
      await PermissionsAndroid.request(
        PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE,
      );
      await PermissionsAndroid.request(
        PermissionsAndroid.PERMISSIONS.READ_EXTERNAL_STORAGE,
      );
    }
    let dirs = ReactNativeBlobUtil.fs.dirs;
    ReactNativeBlobUtil.config({
      fileCache: true,
      appendExt: 'pdf',
      addAndroidDownloads: {
        useDownloadManager: true,
        notification: true,
        path:  dirs.DownloadDir + '/' + 'test.pdf',
      },
    })
      .fetch(
        'GET',
        'API' + item.fileId,
        {
          Authorization: 'Bearer ' + accessTokenForProject?._W,
          'Content-Type': 'multipart/form-data',
        },
      )
      .then((res) => {
        console.log(res);
        let status = res.info().status;
        console.log('The file saved to ', res.path());
        console.log(status);
        if (status == 200) {
          console.log('200');
        }
      })
      .catch((errorMessage, statusCode) => {
        console.log(statusCode, errorMessage);
      });
  };

I'm using Android Emulator Pixel 4a with Android 11, but this code don't working in physical smartfon like Galaxy Note 9 and Xiaomi Mi 9T too.

Linking Error due to Missing File

react-native: 0.64.2
react-native-blob-util: ^0.13.11"

Hi, when i run react-native link react-native-blob-util, it returned:
Error: Cannot find module 'C:\Projects\..........\node_modules\react-native-blob-util\scripts\prelink.js'

is there anyway to solve this issue?

I also tried to install the package through the command below, but error still occur
npm install --save github:RonRadtke/react-native-blob-util#<branch_name>

Attempt to invoke virtual method 'java.lang.String java.io.File.getAbsolutePath()' on a null object reference

"react-native": "^0.63.4",
"react-native-blob-util": "^0.13.6",

I'm seeing the following error on my android emulator SDK version 22 with no SDCard.

[Mon Apr 26 2021 15:02:20.360]  ERROR    Error: Exception in HostObject::get(propName:ReactNativeBlobUtil): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.io.File.getAbsolutePath()' on a null object reference
[Mon Apr 26 2021 15:02:20.360]  ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)
[Mon Apr 26 2021 15:02:20.370]  ERROR    Invariant Violation: Module AppRegistry is not a registered callable module (calling runApplication)

It appears to be an issue with the code in ReactNativeBlobUtilFS.java file line 264 or 281 and I believe it's the same as this stackoverflow.
https://stackoverflow.com/a/20548378

openDocument crashes on iOS simulator in M1 Mac

Summary

ios.openDocument crashes on iOS simulator in M1 Mac. Intel Mac and devices are fine.

After digging into the log, I found that it attempts to insert nil object and causes the error:

terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[2]'
CoreSimulator 776.3 - Device: iPhone 12 (49387E45-4995-4855-AD6E-759014AEC92F) - Runtime: iOS 15.0 (19A339) - DeviceType: iPhone 12

_LSContextInitReturningError() failed with error Error Domain=NSOSStatusErrorDomain Code=-10817 "(null)" UserInfo={_LSFunction=_LSSchemaConfigureForStore, ExpectedSimulatorHash={length = 32, bytes = 0xc23586de 989aecf6 5ff8a488 dbce0d00 ... aafa3d0b e8264735 }, _LSLine=405, WrongSimulatorHash={length = 32, bytes = 0x11a75a6a a465e974 78717d01 63b2e7ac ... 5a568f54 1b7dc131 }}

Screen Shot 2021-11-15 at 16 41 21

Info:

version: v0.13.16

System:
    OS: macOS 11.5.2
    CPU: (8) arm64 Apple M1
    Memory: 95.31 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.8.0 - ~/.nodenv/versions/16.8.0/bin/node
    Yarn: 1.22.11 - ~/.nodenv/versions/16.8.0/bin/yarn
    npm: 7.21.0 - ~/.nodenv/versions/16.8.0/bin/npm
    Watchman: 2021.10.18.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: Not Found
  SDKs:
    iOS SDK:
      Platforms: iOS 15.0, DriverKit 20.4, macOS 11.3, tvOS 15.0, watchOS 8.0
    Android SDK:
      API Levels: 29, 30
      Build Tools: 30.0.2, 30.0.3
      System Images: android-29 | Intel x86 Atom, android-30 | Google APIs ARM 64 v8a, android-30 | Google APIs Intel x86 Atom, android-30 | Google Play ARM 64 v8a, android-31 | Google APIs ARM 64 v8a
      Android NDK: Not Found
  IDEs:
    Android Studio: Arctic Fox 2020.3.1 Patch 3 Arctic Fox 2020.3.1 Patch 3
    Xcode: 13.0/13A233 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_282 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: 0.66.0 => 0.66.0 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

In Android not able to read Arabic translation JSON file using JSONStream

Arabic translation JSON file is downloaded to document directory and it is reading and parsing using RNFetchBlob.JSONStream.

Issue:
In android when we tried to read Arabic translation file using JSONStream the callbacks done or fail in not getting called. And not throwing any exceptions.
In iOS JSONStream is calling done block once the same Arabic json file read complete.

Please note: I have checked this with joltup/rn-fetch-blob
but I also tried to install the latest version of this library, and the result is same.

[Android] actionViewIntent - activity won't start on Android 11+

If your app target Android API 30+ (and use Android 11 device),
using ReactNativeBlobUtil.android.actionViewIntent(path, "application/pdf"); may do nothing.

After investing code, startActivity is not called because resolveActivity always return null here:

if (intent.resolveActivity(pm) != null) {
this.getReactApplicationContext().startActivity(intent);
}

This is due to new Android 11 package visibility.
I found a very interesting article that recommend do no not use resolveActivity - startActivity pattern to avoid potential issues.
See: https://cketti.de/2020/09/03/avoid-intent-resolveactivity/

Why not using try catch method for all Android version like here:

try {
this.getReactApplicationContext().startActivity(intent);
promise.resolve(true);
} catch (ActivityNotFoundException ex) {
promise.reject("ENOAPP", "No app installed for " + mime);
}

and that handle promise resolve/reject correctly.
(this workaround fix my issue with Android 11+ devices)

Full example to reproduce:

// url = url to a pdf file
const PDF_PATH = `${ReactNativeBlobUtil.fs.dirs.CacheDir}/pdfs/Document.pdf`;
const res = await ReactNativeBlobUtil.config({
  fileCache: true,
  appendExt: "pdf",
  path: PDF_PATH
}).fetch("GET", url);
if (res) {
  ReactNativeBlobUtil.android.actionViewIntent(
    res.path(),
    "application/pdf"
  );
}

Further more, actionViewIntent promise is only resolved for Android SDK < 24


Is this normal ?

Custom Fetch Wrapper

I want to ask about creating a custom fetch wrapper. I used to use my custom fetch when I use rn-fetch-blob (sample code is blow).
image

When I tried to replace it with rn-fetch-blob-util, it didn't work. I couldn't get error message. I have searched documentations on the Internet. Couldn't see what I searched.

Is there any changes in rn-fetch-blob-util? What should I do? Can somebody help me?

Android download progress

Hi, first of all thanks for taking up this project! I have more of a question rather than an issue.

Over on the joltup version of this there has been an ongoing issue w/ download progress on Android not working. It seems to be that if useDownloadManager: true no progress events fire back at all.

I'm just wondering if this has been fixed or if not, is it on the radar? I'm happy to help test/give more info if I can!

Android error: Error while casting ReactNativeBlobUtilFileResp

Hello, thanks for taking your time to maintain this library.
Somedays, ago, the "download" stopped working. I was able to track down and fix the issue (credits to @srbulovicdusan).

So, here's an image of the error
image

The fix is,

  1. go to ReactNativeBlobUtilFileResp.java and add a new constructor like this:
public ReactNativeBlobUtilFileResp(ResponseBody body) {
  super();
  this.originalBody = body;
}

then, in ReactNativeBlobUtilReq.java around line 607 replace how ReactNativeBlobUtilFileResp is instanciated.

// remove or comment
ReactNativeBlobUtilFileResp = (ReactNativeBlobUtilFileResp) responseBody;
// use this
ReactNativeBlobUtilFileResp = new ReactNativeBlobUtilFileResp(responseBody);

Important information:

  1. RN version: 0.64.2
  2. lib. version: 0.13.18

Note: I was not able to reproduce this issue on a "clean" RN project.

Fix found here

Insecure Implementation of the HostnameVerifier Causes Play Store Rejection

Version: 0.13.16

My app is being rejected by google for having an insecure implementation of the HostnameVerifier interface.

Based on their steps to resolve:
If you are using the HostnameVerifier interface, change the implementation of the verify method to return false whenever the hostname of the server does not meet your expectations.

It looks like this line in ReactNativeBlobUtilUtils is implemented incorrectly as it is returning true for all verification attempts.

builder.hostnameVerifier(new HostnameVerifier() {
      @Override
      public boolean verify(String hostname, SSLSession session) {
          return true;
      }
  });

Android - Exception in HostObject::get(propName:ReactNativeBlobUtil)

Version: 0.13.7
OS: Android 11 (Samsung Note 10+)
Possibly related to: #33

The following crash is happening randomly (seen from our reporting tool) on android while the app is in background, presumably right before getting killed:

com.facebook.react.common.JavascriptException: Error: Exception in HostObject::get(propName:ReactNativeBlobUtil): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.io.File.getAbsolutePath()' on a null object reference, stack:
<unknown>@856:161
v@2:1473
<unknown>@855:127
v@2:1473
<unknown>@852:176
v@2:1473
<unknown>@851:173
v@2:1473
<unknown>@804:153
v@2:1473
<unknown>@431:408
v@2:1473
d@2:875
<unknown>@6:1625
y@11:586
<unknown>@11:1889
y@11:586
o@11:1065
<unknown>@11:1208
f@127:154
<unknown>@127:881
x@132:655
y@132:1019
callImmediates@132:3084
callImmediates@-1
value@43:3106
<unknown>@43:1282
value@43:2798
value@43:1252
value@-1
value@-1

        at com.facebook.react.modules.core.ExceptionsManagerModule.reportException(ExceptionsManagerModule.java:79)
        at java.lang.reflect.Method.invoke(Method.java:-2)
        at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
        at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151)
        at com.facebook.react.bridge.queue.NativeRunnable.run(NativeRunnable.java:-2)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
        at android.os.Looper.loop(Looper.java:246)
        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:226)
        at java.lang.Thread.run(Thread.java:923)

Basically, this:

com.facebook.react.common.JavascriptException: Error: Exception in HostObject::get(propName:ReactNativeBlobUtil): java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.io.File.getAbsolutePath()' on a null object

Looking at the breadcrumbs, it looks like the user opened the app, but it never entered in foreground mode. The app works fine with normal use, and all permissions are properly defined in manifest and whatsoever.

I'm also loading some folders from the config.js file (loaded pretty much right after app start) like this:

import ReactNativeBlobUtil from 'react-native-blob-util';

// this is basically somewhere else so there's no hard dependencies to the library
let fs = {};
fs.ls = ReactNativeBlobUtil.fs.ls;
fs.mkdir = ReactNativeBlobUtil.fs.mkdir;
fs.df = ReactNativeBlobUtil.fs.df;
fs.dirs = ReactNativeBlobUtil.fs.dirs;

...

const DOCS_DIR = fs.dirs.DocumentDir;
const CACHE_DIR = fs.dirs.CacheDir;
const DOCS_DIR_S = DOCS_DIR + '/';

[Feature] iOS set file / folder attributes

Hello,

We already have ReactNativeBlobUtil.ios.excludeFromBackupKey for iOS. It would be great to also have a way to change file attributes (e.g., to set NSFileProtectionKey on files and folders).

Thoughts on how to accomplish this? I guess we could copy something like this https://github.com/itinance/react-native-fs/blob/master/RNFSManager.m#L123

Rather than a new method, it could also be part of mkdir and writeFile. But if we want to follow the same idea of excludeFromBackupKey, it really has to be a new method

TypeError: null is not an object

env
os: macOS 10.15.7
mobile device : Motorolla power one, running stock android10
react-native-blob-util version: 0.13.7
react-native: 0.61.5

AndroidManifest.xml

...
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
....
<application
    ...
    android:requestLegacyExternalStorage="true"
>
...

code

import ReactNativeBlobUtil from 'react-native-blob-util'


const tempImageUri = await ReactNativeBlobUtil.config({ fileCache: true }).fetch(`${image_url}`)

error

TypeError : null is not an object (evaluating 'ReactNativeBlobUtil.DocumentDir')

Any idea where I might be going wrong?

java.lang.IllegalStateException: cannot make a new request because the previous response is still open: please call response.close()

the version of installed library and RN project.
i'm using master branch: 7f82a51

The library crashes on Interceptor:

09-15 14:36:04.279  4490  5680 E AndroidRuntime: java.lang.IllegalStateException: cannot make a new request because the previous response is still open: please call response.close()
09-15 14:36:04.279  4490  5680 E AndroidRuntime: 	at okhttp3.internal.connection.Transmitter.newExchange(Transmitter.java:164)
09-15 14:36:04.279  4490  5680 E AndroidRuntime: 	at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:41)
09-15 14:36:04.279  4490  5680 E AndroidRuntime: 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
09-15 14:36:04.279  4490  5680 E AndroidRuntime: 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
09-15 14:36:04.279  4490  5680 E AndroidRuntime: 	at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:94)
09-15 14:36:04.279  4490  5680 E AndroidRuntime: 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
09-15 14:36:04.279  4490  5680 E AndroidRuntime: 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
09-15 14:36:04.279  4490  5680 E AndroidRuntime: 	at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
09-15 14:36:04.279  4490  5680 E AndroidRuntime: 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
09-15 14:36:04.279  4490  5680 E AndroidRuntime: 	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:88)
09-15 14:36:04.279  4490  5680 E AndroidRuntime: 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
09-15 14:36:04.279  4490  5680 E AndroidRuntime: 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
09-15 14:36:04.279  4490  5680 E AndroidRuntime: 	at com.ReactNativeBlobUtil.ReactNativeBlobUtilReq$2.intercept(ReactNativeBlobUtilReq.java:437)
09-15 14:36:04.279  4490  5680 E AndroidRuntime: 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:142)
09-15 14:36:04.279  4490  5680 E AndroidRuntime: 	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:117)
09-15 14:36:04.279  4490  5680 E AndroidRuntime: 	at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:229)
09-15 14:36:04.279  4490  5680 E AndroidRuntime: 	at okhttp3.RealCall$AsyncCall.execute(RealCall.java:172)
09-15 14:36:04.279  4490  5680 E AndroidRuntime: 	at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
09-15 14:36:04.279  4490  5680 E AndroidRuntime: 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
09-15 14:36:04.279  4490  5680 E AndroidRuntime: 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
09-15 14:36:04.279  4490  5680 E AndroidRuntime: 	at java.lang.Thread.run(Thread.java:929)

Workaround is available here: square/okhttp#4986 (comment) but i can't figure out how to apply it

react native info:

yarn run v1.22.10
$ /Users/ilia/mytours/mytours-rn/node_modules/.bin/react-native info
info Fetching system and libraries information...
System:
    OS: macOS 11.3.1
    CPU: (8) arm64 Apple M1
    Memory: 650.31 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.8.0 - /var/folders/85/2xpmzxms1tsgzr9nqnhszzfw0000gn/T/yarn--1631677580033-0.9245969333433577/node
    Yarn: 1.22.10 - /var/folders/85/2xpmzxms1tsgzr9nqnhszzfw0000gn/T/yarn--1631677580033-0.9245969333433577/yarn
    npm: 7.21.0 - /opt/homebrew/bin/npm
    Watchman: 2021.08.23.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /Users/ilia/.rbenv/shims/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
    Android SDK: Not Found
  IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.7199119
    Xcode: 12.5.1/12E507 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.12 - /opt/homebrew/opt/openjdk@11/bin/javac
    Python: 2.7.16 - /usr/bin/python
  npmPackages:
    @react-native-community/cli: Not Found
    react: 16.11.0 => 16.11.0
    react-native: 0.62.3 => 0.62.3
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found
✨  Done in 2.44s.

Race condition sometimes resulting in Error: Failed to create parent directory

environment
react-native-blob-util version: 0.13.6
react-native: 0.66.1

code (simplified)

yield* all({
    result1: yield* call(() => RNBlobUtil.fs.writeFile(path1, data1, 'utf8')),
    result2: yield* call(() => RNBlobUtil.fs.writeFile(path2, data2, 'utf8'))
})

error

Error: Failed to create parent directory of '/data/user/0/tuerantuer.app.integreat/files/content/v1/lkvechta/bg/pois.json'

possible explanation
While I was not able to reproduce the error myself, we got some reports via sentry about this issue. It seems like this happens sometimes because of a race condition (e.g. with redux-saga) if attempting to create two files in the same not yet existing directory. Possible execution order:

  • First call to writeFile gets result that parent directory does not exist
  • Second call to writeFile gets result that parent directory does not exist
  • First call to writeFile creates parent directory
  • Second call to writeFile tries to create parent directory but gets result false from Java.io.File.mkdirs() since parent directory does already exist
  • Second call to writeFile throws Failed to create parent directory exception

proposed solution
Only throw an exception if the parent directory does still not exist after attempting to create parent directory, i.e. replace

if (!dir.mkdirs()) {
    promise.reject("ENOTDIR", "Failed to create parent directory of '" + path + "'");
    return;
}

with

if (!dir.mkdirs() && !dir.exists()) {
    promise.reject("ENOTDIR", "Failed to create parent directory of '" + path + "'");
    return;
}

Corresponding lines: https://github.com/joltup/rn-fetch-blob/blob/dcbde6f7e12b666b9fe1c8c4a8e2cb04e0048326/android/src/main/java/com/RNFetchBlob/RNFetchBlobFS.java#L61

Created a PR for this: #85

Thanks for maintaining this project btw 🙏

How to ignore file data

Hello, I'm attempting to use this package to develop a speed test utility for my RN app. I don't need to use the data I am downloading and am having out of memory issues on Android. I would like to just ignore file data entirely if possible, but get updates at a specific interval. This is what I have so far:

export function makeRequest({ target, isUpload, onStart, onDelta }: MakeRequestOptions) {
  return new Promise((resolve, reject) => {
    let bytesReceived = 0;
    let bytesSent = 0;
    
    const task = isUpload
      ? ReactNativeBlobUtil.config({ fileCache: true }).fetch(
          "POST",
          target,
          { "Content-Type": "text/plain", "Content-Length": UPLOAD_FILE_DATA.length.toString() },
          UPLOAD_FILE_DATA,
        )
      : ReactNativeBlobUtil.config({ fileCache: true }).fetch("GET", target);

    task
      .progress({ interval: 250 }, (received) => {
        console.log("received", received);
        if (!isUpload) {
          onDelta({ delta: received - bytesReceived });
          bytesReceived = received;
        }
      })
      .uploadProgress({ interval: 250 }, (written) => {
        if (isUpload) {
          onDelta({ delta: written - bytesSent });
          bytesSent = written;
        }
      })
      .then(() => {
        resolve(undefined);
      })
      .catch((e) => {
        console.error("IN THE ERROR", e);
        reject(e);
      });

    onStart({
      abort: () =>
        task.cancel(() => {
          resolve(undefined);
        }),
    });
  });
}

Symbol collision with rn-fetch-blob

Our project uses redux-persist and ran into an issue on Android loading large state with AsyncStorage. Switching from AsyncStorage to redux-persist-filesystem-storage (which uses react-native-blob-util) works great to fix Android.

However, we ran into a problem with iOS because we also use react-native-pdf which requires rn-fetch-blob. The result is that react-native-blob-util and rn-fetch-blob are both declared, resulting in errors about duplicate symbols.

Is this something that could be addressed by changing the symbols in react-native-blob-util, and is that the best way to go?

❌  duplicate symbol '_bridgeRef' in
> libreact-native-blob-util.a(ReactNativeBlobUtil.o)
> librn-fetch-blob.a(RNFetchBlob.o)


❌  duplicate symbol '_fsQueue' in
> libreact-native-blob-util.a(ReactNativeBlobUtil.o)
> librn-fetch-blob.a(RNFetchBlob.o)


❌  duplicate symbol '_commonTaskQueue' in
> libreact-native-blob-util.a(ReactNativeBlobUtil.o)
> librn-fetch-blob.a(RNFetchBlob.o)


❌  duplicate symbol '_fileStreams' in
> libreact-native-blob-util.a(ReactNativeBlobUtilFS.o)
> librn-fetch-blob.a(RNFetchBlobFS.o)


❌  duplicate symbol '_expirationTable' in
> libreact-native-blob-util.a(ReactNativeBlobUtilNetwork.o)
> librn-fetch-blob.a(RNFetchBlobNetwork.o)

Unable to open PDF file on Android 11 - targetSdkVersion 30

Hello,

I've been using this library (the former repo) for quite some time in order to open PDF files.
Recently, I've updated Android's targetSdkVersion to 30, and I've noticed the actionViewIntent function is not functioning on Android 11.
Using it as: android.actionViewIntent(filePath, `application/pdf`);

No error or whatsoever is thrown, so not really possible to apport more specific information.

Currently, asking for these permissions on AndroidManifest.xml:

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

And have bothpreserveLegacyExternalStorage & requestLegacyExternalStorage set as true.

Using latest "react-native-blob-util": "0.13.15" version

Has somebody else faced this issue after updating?
Am I missing some specific settings?

Thanks in advance.

EDIT:

Paths were I've tested to open the .pdf from (emulator):

/data/user/0/com.{app_bundle}/cache/{....}.pdf
/storage/emulated/0/Documents/{....}.pdf

when I am create .aab in android application get crash on launch show following error

when I am creating .aab in the android application get crashes on launch App.

npm is working fine if we generate release apk but now google play only takes .aab bundle.

On app open show following error in android studio log.

This line is also added in AndroidManifest.xml
android:requestLegacyExternalStorage="true"

"react-native": "0.63.3",
"react-native-blob-util": "^0.13.14",
Android version 8,10,11

image

If we change storage again we received this error.

image

Android build fails after upgrade to RN 0.65

react-native-blob-util 0.13.14
react-native 0.66.0-rc.3

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-blob-util:generateReleaseRFile'.
> Could not resolve all files for configuration ':react-native-blob-util:releaseCompileClasspath'.
   > Could not resolve com.squareup.okhttp3:okhttp:3.12.+.
     Required by:
         project :react-native-blob-util
      > Failed to list versions for com.squareup.okhttp3:okhttp.
         > Unable to load Maven meta-data from https://www.jitpack.io/com/squareup/okhttp3/okhttp/maven-metadata.xml.
            > Could not get resource 'https://www.jitpack.io/com/squareup/okhttp3/okhttp/maven-metadata.xml'.
               > Could not GET 'https://www.jitpack.io/com/squareup/okhttp3/okhttp/maven-metadata.xml'.
                  > The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/6.9/userguide/build_environment.html#gradle_system_properties
                     > PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
   > Could not resolve com.squareup.okhttp3:okhttp-urlconnection:3.12.+.
     Required by:
         project :react-native-blob-util
      > Failed to list versions for com.squareup.okhttp3:okhttp-urlconnection.
         > Unable to load Maven meta-data from https://www.jitpack.io/com/squareup/okhttp3/okhttp-urlconnection/maven-metadata.xml.
            > Could not get resource 'https://www.jitpack.io/com/squareup/okhttp3/okhttp-urlconnection/maven-metadata.xml'.
               > Could not GET 'https://www.jitpack.io/com/squareup/okhttp3/okhttp-urlconnection/maven-metadata.xml'.
                  > The server may not support the client's requested TLS protocol versions: (TLSv1.2, TLSv1.3). You may need to configure the client to allow other protocols to be used. See: https://docs.gradle.org/6.9/userguide/build_environment.html#gradle_system_properties
                     > PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

This error seems to occur because of the change from jcenter() to mavenCentral() from RN 0.64 to 0.65. If I revert to jcenter(), then my app builds just fine.
Screen Shot 2021-09-20 at 10 35 34 AM

android build error after upgrading RN to 0.66.1

After upgrading RN from 0.64.3 to 0.66.1 I got these issues while gradle build;

`FAILURE: Build failed with an exception.

  • Where:
    Build file '/Users/ogge/gitlab/client/mobile-branch/node_modules/react-native-blob-util/android/build.gradle' line: 71

    variant.javaCompileProvider.get().classpath.files

  • What went wrong:
    A problem occurred configuring project ':react-native-blob-util'.

Could not resolve all files for configuration ':react-native-blob-util:debugCompileClasspath'.
Failed to transform react-native-0.66.1.aar (com.facebook.react:react-native:0.66.1) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for AarToClassTransform: /Users/ogge/.gradle/caches/transforms-3/fd230f9f99ee8d8aba366ad28e366264/transformed/jetified-react-native-0.66.1.aar.
> /Users/ogge/.gradle/caches/transforms-3/fd230f9f99ee8d8aba366ad28e366264/transformed/jetified-react-native-0.66.1.aar (No such file or directory)
Failed to transform infer-annotation-0.18.0.jar (com.facebook.infer.annotation:infer-annotation:0.18.0) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for IdentityTransform: /Users/ogge/.gradle/caches/transforms-3/22b5f77369671d9580db39078b8ddafa/transformed/jetified-infer-annotation-0.18.0.jar.
> File/directory does not exist: /Users/ogge/.gradle/caches/transforms-3/33c44f5fe84672f869db208467880345/transformed/jetified-jsr305-3.0.2.jar
Failed to transform jsr305-3.0.2.jar (com.google.code.findbugs:jsr305:3.0.2) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for IdentityTransform: /Users/ogge/.gradle/caches/transforms-3/33c44f5fe84672f869db208467880345/transformed/jetified-jsr305-3.0.2.jar.
> File/directory does not exist: /Users/ogge/.gradle/caches/transforms-3/33c44f5fe84672f869db208467880345/transformed/jetified-jsr305-3.0.2.jar
Failed to transform kotlin-annotations-jvm-1.3.72.jar (org.jetbrains.kotlin:kotlin-annotations-jvm:1.3.72) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for IdentityTransform: /Users/ogge/.gradle/caches/transforms-3/613d7c7f9bf82af4930cc79507a5ce5b/transformed/jetified-kotlin-annotations-jvm-1.3.72.jar.
> File/directory does not exist: /Users/ogge/.gradle/caches/transforms-3/33c44f5fe84672f869db208467880345/transformed/jetified-jsr305-3.0.2.jar
Failed to transform proguard-annotations-1.19.0.jar (com.facebook.yoga:proguard-annotations:1.19.0) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.jvm.version=7, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for IdentityTransform: /Users/ogge/.gradle/caches/transforms-3/5aa05c299b265108d886e0cf68c99250/transformed/jetified-proguard-annotations-1.19.0.jar.
> File/directory does not exist: /Users/ogge/.gradle/caches/transforms-3/33c44f5fe84672f869db208467880345/transformed/jetified-jsr305-3.0.2.jar
Failed to transform javax.inject-1.jar (javax.inject:javax.inject:1) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for IdentityTransform: /Users/ogge/.gradle/caches/transforms-3/56dbb217dc85f32971f2748632655d11/transformed/jetified-javax.inject-1.jar.
> File/directory does not exist: /Users/ogge/.gradle/caches/transforms-3/33c44f5fe84672f869db208467880345/transformed/jetified-jsr305-3.0.2.jar
Failed to transform autofill-1.1.0.aar (androidx.autofill:autofill:1.1.0) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for AarToClassTransform: /Users/ogge/.gradle/caches/transforms-3/c0f09cf12b8e21b8b61c77272a0e9f7d/transformed/jetified-autofill-1.1.0.aar.
> /Users/ogge/.gradle/caches/transforms-3/c0f09cf12b8e21b8b61c77272a0e9f7d/transformed/jetified-autofill-1.1.0.aar (No such file or directory)
Failed to transform fresco-2.5.0.aar (com.facebook.fresco:fresco:2.5.0) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for AarToClassTransform: /Users/ogge/.gradle/caches/transforms-3/bfd87dce7f0f45a8fad452478ee5ddf2/transformed/jetified-fresco-2.5.0.aar.
> /Users/ogge/.gradle/caches/transforms-3/bfd87dce7f0f45a8fad452478ee5ddf2/transformed/jetified-fresco-2.5.0.aar (No such file or directory)
Failed to transform fbcore-2.5.0.aar (com.facebook.fresco:fbcore:2.5.0) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for AarToClassTransform: /Users/ogge/.gradle/caches/transforms-3/21ebd7982dcb5c18d6062c2341579796/transformed/jetified-fbcore-2.5.0.aar.
> /Users/ogge/.gradle/caches/transforms-3/21ebd7982dcb5c18d6062c2341579796/transformed/jetified-fbcore-2.5.0.aar (No such file or directory)
Failed to transform soloader-0.10.1.aar (com.facebook.soloader:soloader:0.10.1) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for AarToClassTransform: /Users/ogge/.gradle/caches/transforms-3/367d31367351654fa737409b3bf42339/transformed/jetified-soloader-0.10.1.aar.
> /Users/ogge/.gradle/caches/transforms-3/367d31367351654fa737409b3bf42339/transformed/jetified-soloader-0.10.1.aar (No such file or directory)
Failed to transform annotation-0.10.1.jar (com.facebook.soloader:annotation:0.10.1) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for IdentityTransform: /Users/ogge/.gradle/caches/transforms-3/1de81763ff23ccf6c21a1e3b5e8e5684/transformed/jetified-annotation-0.10.1.jar.
> File/directory does not exist: /Users/ogge/.gradle/caches/transforms-3/33c44f5fe84672f869db208467880345/transformed/jetified-jsr305-3.0.2.jar
Failed to transform nativeloader-0.10.1.jar (com.facebook.soloader:nativeloader:0.10.1) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for IdentityTransform: /Users/ogge/.gradle/caches/transforms-3/5a2b6eb034dd42ce3e42b5e032cc5667/transformed/jetified-nativeloader-0.10.1.jar.
> File/directory does not exist: /Users/ogge/.gradle/caches/transforms-3/33c44f5fe84672f869db208467880345/transformed/jetified-jsr305-3.0.2.jar
Failed to transform ui-common-2.5.0.aar (com.facebook.fresco:ui-common:2.5.0) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for AarToClassTransform: /Users/ogge/.gradle/caches/transforms-3/ef18b333dc28485cd4ebfd1a067f791e/transformed/jetified-ui-common-2.5.0.aar.
> /Users/ogge/.gradle/caches/transforms-3/ef18b333dc28485cd4ebfd1a067f791e/transformed/jetified-ui-common-2.5.0.aar (No such file or directory)
Failed to transform drawee-2.5.0.aar (com.facebook.fresco:drawee:2.5.0) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for AarToClassTransform: /Users/ogge/.gradle/caches/transforms-3/a32319ae963e1fc640980c95cc8677d0/transformed/jetified-drawee-2.5.0.aar.
> /Users/ogge/.gradle/caches/transforms-3/a32319ae963e1fc640980c95cc8677d0/transformed/jetified-drawee-2.5.0.aar (No such file or directory)
Failed to transform imagepipeline-2.5.0.aar (com.facebook.fresco:imagepipeline:2.5.0) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for AarToClassTransform: /Users/ogge/.gradle/caches/transforms-3/dfb6d4890b87db3ac7a1eee5ef3c8a75/transformed/jetified-imagepipeline-2.5.0.aar.
> /Users/ogge/.gradle/caches/transforms-3/dfb6d4890b87db3ac7a1eee5ef3c8a75/transformed/jetified-imagepipeline-2.5.0.aar (No such file or directory)
Failed to transform imagepipeline-base-2.5.0.aar (com.facebook.fresco:imagepipeline-base:2.5.0) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for AarToClassTransform: /Users/ogge/.gradle/caches/transforms-3/96c822867203f47958e7f15a1ef7b04c/transformed/jetified-imagepipeline-base-2.5.0.aar.
> /Users/ogge/.gradle/caches/transforms-3/96c822867203f47958e7f15a1ef7b04c/transformed/jetified-imagepipeline-base-2.5.0.aar (No such file or directory)
Failed to transform imagepipeline-native-2.5.0.aar (com.facebook.fresco:imagepipeline-native:2.5.0) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for AarToClassTransform: /Users/ogge/.gradle/caches/transforms-3/4f5ebc8e3c7280b5a3e98b1c7702752d/transformed/jetified-imagepipeline-native-2.5.0.aar.
> /Users/ogge/.gradle/caches/transforms-3/4f5ebc8e3c7280b5a3e98b1c7702752d/transformed/jetified-imagepipeline-native-2.5.0.aar (No such file or directory)
Failed to transform memory-type-ashmem-2.5.0.aar (com.facebook.fresco:memory-type-ashmem:2.5.0) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for AarToClassTransform: /Users/ogge/.gradle/caches/transforms-3/024563af9087f4bd0f19430b0edf5d6d/transformed/jetified-memory-type-ashmem-2.5.0.aar.
> /Users/ogge/.gradle/caches/transforms-3/024563af9087f4bd0f19430b0edf5d6d/transformed/jetified-memory-type-ashmem-2.5.0.aar (No such file or directory)
Failed to transform memory-type-native-2.5.0.aar (com.facebook.fresco:memory-type-native:2.5.0) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for AarToClassTransform: /Users/ogge/.gradle/caches/transforms-3/8a59e12db255f05cb0ed32e6acba4713/transformed/jetified-memory-type-native-2.5.0.aar.
> /Users/ogge/.gradle/caches/transforms-3/8a59e12db255f05cb0ed32e6acba4713/transformed/jetified-memory-type-native-2.5.0.aar (No such file or directory)
Failed to transform memory-type-java-2.5.0.aar (com.facebook.fresco:memory-type-java:2.5.0) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for AarToClassTransform: /Users/ogge/.gradle/caches/transforms-3/4aa20566f9424dbb8d7798b1a676c6a9/transformed/jetified-memory-type-java-2.5.0.aar.
> /Users/ogge/.gradle/caches/transforms-3/4aa20566f9424dbb8d7798b1a676c6a9/transformed/jetified-memory-type-java-2.5.0.aar (No such file or directory)
Failed to transform nativeimagefilters-2.5.0.aar (com.facebook.fresco:nativeimagefilters:2.5.0) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for AarToClassTransform: /Users/ogge/.gradle/caches/transforms-3/2737686cbd40f028d7ca253f81efdfbe/transformed/jetified-nativeimagefilters-2.5.0.aar.
> /Users/ogge/.gradle/caches/transforms-3/2737686cbd40f028d7ca253f81efdfbe/transformed/jetified-nativeimagefilters-2.5.0.aar (No such file or directory)
Failed to transform nativeimagetranscoder-2.5.0.aar (com.facebook.fresco:nativeimagetranscoder:2.5.0) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for AarToClassTransform: /Users/ogge/.gradle/caches/transforms-3/d6044e9ef33529ab28d097a96a9691fd/transformed/jetified-nativeimagetranscoder-2.5.0.aar.
> /Users/ogge/.gradle/caches/transforms-3/d6044e9ef33529ab28d097a96a9691fd/transformed/jetified-nativeimagetranscoder-2.5.0.aar (No such file or directory)
Failed to transform imagepipeline-okhttp3-2.5.0.aar (com.facebook.fresco:imagepipeline-okhttp3:2.5.0) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.libraryelements=aar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for AarToClassTransform: /Users/ogge/.gradle/caches/transforms-3/9ea698d40500b970ee7da351fece7e7a/transformed/jetified-imagepipeline-okhttp3-2.5.0.aar.
> /Users/ogge/.gradle/caches/transforms-3/9ea698d40500b970ee7da351fece7e7a/transformed/jetified-imagepipeline-okhttp3-2.5.0.aar (No such file or directory)
Failed to transform okhttp-urlconnection-4.9.1.jar (com.squareup.okhttp3:okhttp-urlconnection:4.9.1) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.jvm.version=8, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api, org.jetbrains.kotlin.localToProject=public, org.jetbrains.kotlin.platform.type=jvm}.
> Execution failed for IdentityTransform: /Users/ogge/.gradle/caches/transforms-3/cad4978a301d22becb3850462a7feffa/transformed/jetified-okhttp-urlconnection-4.9.1.jar.
> File/directory does not exist: /Users/ogge/.gradle/caches/transforms-3/33c44f5fe84672f869db208467880345/transformed/jetified-jsr305-3.0.2.jar
Failed to transform okhttp-4.9.1.jar (com.squareup.okhttp3:okhttp:4.9.1) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.jvm.version=8, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api, org.jetbrains.kotlin.localToProject=public, org.jetbrains.kotlin.platform.type=jvm}.
> Execution failed for IdentityTransform: /Users/ogge/.gradle/caches/transforms-3/b2a3ace5110d379955793c4b7bb55d1f/transformed/jetified-okhttp-4.9.1.jar.
> File/directory does not exist: /Users/ogge/.gradle/caches/transforms-3/33c44f5fe84672f869db208467880345/transformed/jetified-jsr305-3.0.2.jar
Failed to transform okio-jvm-2.9.0.jar (com.squareup.okio:okio:2.9.0) to match attributes {artifactType=android-classes-jar, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api, org.jetbrains.kotlin.platform.type=jvm}.
> Execution failed for IdentityTransform: /Users/ogge/.gradle/caches/transforms-3/c296df021c8d50649c8abbfac33e3e2b/transformed/jetified-okio-jvm-2.9.0.jar.
> File/directory does not exist: /Users/ogge/.gradle/caches/transforms-3/33c44f5fe84672f869db208467880345/transformed/jetified-jsr305-3.0.2.jar
Failed to transform kotlin-stdlib-jdk8-1.4.10.jar (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.10) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for IdentityTransform: /Users/ogge/.gradle/caches/transforms-3/8338921157f3d3e261cae36c4e9aa433/transformed/jetified-kotlin-stdlib-jdk8-1.4.10.jar.
> File/directory does not exist: /Users/ogge/.gradle/caches/transforms-3/33c44f5fe84672f869db208467880345/transformed/jetified-jsr305-3.0.2.jar
Failed to transform kotlin-stdlib-jdk7-1.4.10.jar (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.10) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for IdentityTransform: /Users/ogge/.gradle/caches/transforms-3/f9eb32973940106e9b112e4b99545cb5/transformed/jetified-kotlin-stdlib-jdk7-1.4.10.jar.
> File/directory does not exist: /Users/ogge/.gradle/caches/transforms-3/33c44f5fe84672f869db208467880345/transformed/jetified-jsr305-3.0.2.jar
Failed to transform kotlin-stdlib-1.4.10.jar (org.jetbrains.kotlin:kotlin-stdlib:1.4.10) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for IdentityTransform: /Users/ogge/.gradle/caches/transforms-3/ffd560b2f58ca3dedd248aff25ca202f/transformed/jetified-kotlin-stdlib-1.4.10.jar.
> File/directory does not exist: /Users/ogge/.gradle/caches/transforms-3/33c44f5fe84672f869db208467880345/transformed/jetified-jsr305-3.0.2.jar
Failed to transform kotlin-stdlib-common-1.4.10.jar (org.jetbrains.kotlin:kotlin-stdlib-common:1.4.10) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for IdentityTransform: /Users/ogge/.gradle/caches/transforms-3/e87c819c797b9dc69f8efbd740f7b8c2/transformed/jetified-kotlin-stdlib-common-1.4.10.jar.
> File/directory does not exist: /Users/ogge/.gradle/caches/transforms-3/33c44f5fe84672f869db208467880345/transformed/jetified-jsr305-3.0.2.jar
Failed to transform annotations-13.0.jar (org.jetbrains:annotations:13.0) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for IdentityTransform: /Users/ogge/.gradle/caches/transforms-3/c2e04f005763d1c36a380ec2e6c883ed/transformed/jetified-annotations-13.0.jar.
> File/directory does not exist: /Users/ogge/.gradle/caches/transforms-3/33c44f5fe84672f869db208467880345/transformed/jetified-jsr305-3.0.2.jar
Failed to transform fbjni-java-only-0.2.2.jar (com.facebook.fbjni:fbjni-java-only:0.2.2) to match attributes {artifactType=android-classes-jar, org.gradle.category=library, org.gradle.dependency.bundling=external, org.gradle.jvm.version=8, org.gradle.libraryelements=jar, org.gradle.status=release, org.gradle.usage=java-api}.
> Execution failed for IdentityTransform: /Users/ogge/.gradle/caches/transforms-3/f8db01f3c7d9eb217180d63004ff1f2a/transformed/jetified-fbjni-java-only-0.2.2.jar.
> File/directory does not exist: /Users/ogge/.gradle/caches/transforms-3/33c44f5fe84672f869db208467880345/transformed/jetified-jsr305-3.0.2.jar`

[SOLVERD] Android exception com.react.bridge.ReadableNativeMap cannot be cast to java.lang.String

Hey guys, this appears when trying to do this request
export const getArtwork = () => { return ( ReactNativeBlobUtil.fetch('POST', 'XXXXXXXXXXXX', { 'Content-Type':application/json`,
}, DEFAULT_ARTWORK)
.then(res => {
let status = res.info().status;

    if (status === 200) {
      // the conversion is done in native code
      let base64Str = res.base64();
      // the following conversions are done in js, it's SYNC
      let text = res.text();
      let json = res.json();
      console.log('the base 64')
      console.log(base64Str);
      console.log('text is' )
      console.log(text)
      console.log('json is' )
      console.log(json);
      return res;
    } else {
      // handle other status codes
      console.log('there was an error somehow ')
      console.log(JSON.stringify(res.info()))
    }
  })
  // Something went wrong:
  .catch((errorMessage, statusCode) => {
    console.log('catched error')
    console.log(errorMessage)
    console.log('status code ', statusCode)
    // error handling
  })

);
};`
image

The api works fine, with the old blob-to-base64 it worked, but i want to use the most up to date version.
image

im using the lastest react native version

Not getting continuous upload progress in iOS

Hi,

In iOS the upload progress is not continuous whereas in android is getting continuous progress.

Sample code:

import RNFetchBlob from 'react-native-blob-util';

 const apiPostdata = [
    {
      data: RNFetchBlob.wrap(imageUri),
      filename: imageUri.replace(/^.*[\\\/]/, ''),
      name: imageField,
      type: 'image/jpg'
    },
    ...apiBodyUpdated
  ];

  const apiHeader: Record<string, any> = header || {
    Authorization: `Bearer ${accessToken}`,
    'Content-Type': 'multipart/form-data'
  };

  return RNFetchBlob
    .config({ IOSBackgroundTask: true })
    .fetch('POST', apiUrl, apiHeader, apiPostdata)
    .progress((received, total) => {
      if (progress) {
        progress(received / total);
      }
    })
    .uploadProgress(
      { interval: 1 }, (written, total) => {
        console.log(written / total, 'written / total'); // => always returns 1 in iOS but in android its progress from 0 to 1

        if (progress) {
          progress(written / total);
        }
      }
    )
    .then((res) => {
      if (res.respInfo.status === 201) {
        return res.json();
      }
      return res;
    })
    .catch((error) => Promise.reject(error));

Here in .progress(), written/ total always return 1 in iOS while uploading but in android value ranges from 0 to 1 thus getting a continuous progress.

Versions using:

react-native-blob-util: 0.13.13
react-native: 0.64.0
react: 17.0.1
Android Studio: 4.1 AI-201.8743.12.41.7199119
Xcode: 12.5.1/12E507

In iOS

Screen.Recording.2021-08-30.at.7.30.07.PM.mov

In Android

Screen.Recording.2021-08-30.at.7.32.07.PM.mov

Is there anything that is missing or is it the default behaviour in iOS ?

Thanks.

Windows status

Hello,

Does anyone know the status of Windows implementation in this repository?

I tried using it but was met with some compilation errors, more specifically:

The fetchBlob method is defined like this: winrt::fire_and_forget RNFetchBlob::fetchBlob.

There are also multiple references to RNFetchBlobState .

But these classes declaration do not exist anymore, they were renamed to ReactNativeBlobUtilState and ReactNativeBlobUtil.

Seems like there was an automatic rename done but the code was left broken.

Typo in folder name

Folder name in android folder is still ReactNativeBloBUtil when doing yarn add react-native-blob-util or npm i react-native-blob-util
#26

Incompatible with AGP 7 - Plugin with id 'maven' not found

When building with the newest version of the Android Gradle Plugin 7.0.1 (using Gradle 7.0.2) the following error occurs:

* What went wrong:
A problem occurred evaluating project ':react-native-blob-util'.
> Plugin with id 'maven' not found.

The maven gradle plugin is legacy and has been removed with 7.0.2.

https://docs.gradle.org/7.0/userguide/upgrading_version_6.html#removal_of_the_legacy_maven_plugin

The solution would be to use the newer maven-publish plugin which is compatible with Gradle 7.

Note that this is using react-native-blob-util version 0.13.15.

Stuck at start screen, can't close splash screen after install (Only ios)

env
os: macOS 10.15.6
devices: iphone 8, 11, ...

Dependencies:
"react": "17.0.1",
"react-native": "0.64.0",
"react-native-blob-util": "^0.13.7",
"react-native-bootsplash": "~3.2.0",

Example code:
const configOptions: ReactNativeBlobUtilConfig = {
path: dirs.DownloadDir + /${downloadName},
trusty: true,
fileCache: true,
appendExt: 'xlsx' || 'pdf' || 'docx',
};
if (Platform.OS === 'android') {
configOptions['addAndroidDownloads'] = {
useDownloadManager: true,
notification: true,
title: strSuccess,
}
}
ReactNativeBlobUtil.config(configOptions)
.fetch('GET', downloadUrl, {
Accept: 'application/json',
'Content-Type': 'application/json',
Authorization: Token,
}).then().catch();

Empty PDF file on IOS

  • please provide the version of installed library and RN project. : RN 0.64.2, RNBlobUtil 0.13.7
  • a sample code snippet/repository is very helpful to spotting the problem.

Screenshot 2021-08-26 at 11 27 05

When downloading a PDF file through the above method, it works on Android but on IOS, an empty files opens and nothing is to be found inside the iPhone filesystem

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.