标签: rn-fetch-blob

RNFetchBlob.android.actionViewIntent 不适用于 android 11

我已将 my\xc2\xa0Android 的targetSdkVersion更新为30,并且我意识到actionViewIntent函数在 Android 11 上不起作用。

\n

没有抛出错误。所以我无法调试。

\n

下面是我的代码:

\n
RNFetchBlob.android.actionViewIntent(filePath, mimeType);\n
Run Code Online (Sandbox Code Playgroud)\n

更新后还有人遇到这个问题吗?请帮助我!

\n

提前致谢。

\n

android react-native rn-fetch-blob

8
推荐指数
1
解决办法
3021
查看次数

使用 Expo 时如何忽略 fetch() 调用中的 SSL 证书问题?

似乎反应原生无法在 fetch() 调用期间禁用 SSL 验证。有人在这里提到 rn-fetch-blob 可以实现这一点,但正如评论之一提到的 - Expo 与 rn-fetch-blob 不兼容(构建 APK,然后发送到设备会让开发变得痛苦)。人们在这里使用过任何解决方案吗?

注意 -这里有类似的问题,但我正在查询公共域(strengthlevel.com),因此无法控制证书或协议。

fetch react-native expo rn-fetch-blob

7
推荐指数
1
解决办法
1455
查看次数

react-native 如何使用链接打开本地文件 url?

我正在使用以下代码下载文件(可以是 PDF 或 DOC),然后使用链接打开它。

const { dirs } = RNFetchBlob.fs;
let config = {
    fileCache : true,
    appendExt : extension,
    addAndroidDownloads : {
        useDownloadManager : false,
        notification : false,
        title : 'File',
        description : 'A file.',
        path: `${dirs.DownloadDir}/file.${extension}`,
    },
};
RNFetchBlob.config(config)
    .fetch(
        method,
        remoteUrl,
        APIHelpers.getDefaultHeaders()
    )
    .then((res) => {
        let status = res.info().status;
        if (status == 200) {
            Linking.canOpenURL(res.path())
                .then((supported) => {
                    if (!supported) {
                        alert('Can\'t handle url: ' + res.path());
                    } else {
                        Linking.openURL(res.path())
                            .catch((err) => alert('An error occurred …
Run Code Online (Sandbox Code Playgroud)

android ios react-native react-native-linking rn-fetch-blob

6
推荐指数
2
解决办法
4938
查看次数

将 Base64 转换为 png 并保存在设备中 React Native Expo

我一直在尝试使用 React Native 和 Expo 在移动设备上保存图像,我尝试过这些软件包:

import RNFetchBlob from 'react-native-fetch-blob';
import RNfs from 'react-native-fs ';
Run Code Online (Sandbox Code Playgroud)

但在实现它们时都给了我这个错误

null is not an object (evaluating 'RNFetchBlob.DocumentDir')
Run Code Online (Sandbox Code Playgroud)

然后尝试 expo-file-system 但我没有看到任何清晰的示例来说明如何转换 base64 并将其下载到移动设备

更新

我能够做到这一点,我的目的是保存QR的base64并将其转换为png,同时能够共享它,我使用expo-file-system和做到了这一点expo-sharing

这是小米代码,

import * as FileSystem from 'expo-file-system';
import * as Sharing from 'expo-sharing';

//any image, I use it to initialize it

const image_source = 'https://images.unsplash.com/photo-1508138221679-760a23a2285b?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&w=1000&q=80';

share=()=>{
  var self = this;
  self.setState({loading:true})
        FileSystem.downloadAsync(
        image_source,
        FileSystem.documentDirectory  + '.png'
      )
        .then(({ uri }) => {
          console.log(self.state.base64Code);
          FileSystem.writeAsStringAsync(
              uri,
              self.state.base64Code,
              {'encoding':FileSystem.EncodingType.Base64} …
Run Code Online (Sandbox Code Playgroud)

react-native expo rn-fetch-blob

4
推荐指数
1
解决办法
1万
查看次数

RN 从 IOS 中的 URL 获取 blob 下载 docx 或 pdf

做了什么

在 Android 中实现并DCIM directory在 android中特定地下载它。在 ios 中DocumentDir用于下载 pdf 或 docx 文件。使用 "rn-fetch-blob": "^0.12.0";

错误

在 IOS 中,它在控制台中显示消息:

文件保存到/var/mobile/Containers/Data/Application/E6FDC2DD-7FCA-44DC-85C4-A275078F8825/Documents/wow13.pdf

要下载的代码是这样的:

downloadFileOnSuccess = async () => {
    let dirs =
      Platform.OS == 'ios'
        ? RNFetchBlob.fs.dirs.DocumentDir
        : RNFetchBlob.fs.dirs.DCIMDir;
    console.log(dirs, 'document path');
    RNFetchBlob.config({
      // response data will be saved to this path if it has access right.

      fileCache: true,
      path: dirs + `/wow13.pdf`,
    })
      .fetch(
        'GET',
        'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf',
        {
          //some headers ..
        },
      )
      .then(res => { …
Run Code Online (Sandbox Code Playgroud)

ios react-native rn-fetch-blob

3
推荐指数
2
解决办法
9255
查看次数

在 iOS 上安装 pod 时 React Native Fetch Blob 创建问题

我已经安装react-native-fetch-blob在 react-native 上version 0.60.5。当我运行时pod install,错误出现在你可以看到的截屏

请指导我如何解决这个问题

react-native react-native-ios react-native-fetch-blob rn-fetch-blob

3
推荐指数
1
解决办法
1896
查看次数

rn-fetch-blob 错误:RNFetchBlob.fetchBlobForm 未能创建请求正文

async postFileUpload(payload) {
    const rnfetchfile = RNFetchBlob.wrap(payload.uri);
    try {
    console.log(
        'POST',
        'https://******.***.**/******/***/upload_*******_file',
        {
          ...this.config,
          'Content-Type': 'multipart/form-data',
        },
        [
          // element with property `filename` will be transformed into `file` in form data
          {
            name: 'files',
            filename: payload.name,
            data: rnfetchfile.replace('file://file:///', 'file://'),
          },
        ],
      );
      const res = await RNFetchBlob.fetch(
        'POST',
        'https://******.***.**/******/***/upload_*******_file',
        {
          ...this.config,
          'Content-Type': 'multipart/form-data',
        },
        [
          // element with property `filename` will be transformed into `file` in form data
          {
            name: 'files',
            filename: payload.name,
            data: rnfetchfile.replace('file://file:///', 'file://'),
          },
        ],
      );
    const …
Run Code Online (Sandbox Code Playgroud)

reactjs react-native react-redux react-native-ios rn-fetch-blob

3
推荐指数
2
解决办法
5021
查看次数

rn-fetch-blob 包包含无效配置:不允许“dependency.hooks”

rn-fetch-blob 包包含无效配置:不允许“dependency.hooks”。请使用“react-native config”命令验证其是否正确链接,并就此联系软件包维护人员。

package.json - “react-native”:“0.69.2”,“rn-fetch-blob”:“^0.12.0”

dependencies react-native react-hooks rn-fetch-blob

3
推荐指数
1
解决办法
1万
查看次数