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.

Error trying load files from iCloud, Dropbox

See original GitHub issue

Hi, @Elyx0 , first at all, great module for RN, your work is amazing.

I’ve been using your module, quite good, but I face an issue with it.

when trying load files from iCloud or Dropbox, the module it can’t able to find it, also I’ve tried with

but not luck, it throw theses errors.

captura de pantalla 2017-03-16 a las 12 05 32

I’ve been trying all these codes

loadFile(url) {
    console.log("START LOADING FILES");
    setTimeout(() => {
      console.log("LOADING FILES");

      const parts = url.split("/");
      const _parts = url.split("/");
      const name = parts.pop();
      const inbox = parts.pop();
      const mainPath = `${RNFS.MainBundlePath}/${inbox}/${name}`;
      const cachaPath = `${RNFS.CachesDirectoryPath}/${inbox}/${name}`;
      const documentPath = `${RNFS.DocumentDirectoryPath}/${inbox}/${name}`;
      const tmpPath = `${RNFS.TemporaryDirectoryPath}/${inbox}/${name}`;

      _parts.shift();
      _parts.shift();
      _parts.shift();
      _parts.shift();

      const _url = _parts.join("/");

      // URL
      RNFetchBlob.fs.stat(`/${_url}`)
        .then((file) => {
          console.log("_url SUCCESS", file);
          file.path = url;
          //uploadFile(file);
        })
        .catch((err) => {
          console.log("_url => ERROR", err)
        });

      RNFS.stat(`/${_url}`)
        .then((file) => {
          console.log("RNFS _url SUCCESS", file);
        })
        .catch((err) => {
          console.log("RNFS _url ERROR", err);
        });

      RNFS.stat(url)
        .then((file) => {
          console.log("RNFS URL SUCCESS", file);
        })
        .catch((err) => {
          console.log("RNFS URL ERROR", err);
        });

      RNFS.stat(mainPath)
        .then((file) => {
          console.log("RNFS mainPath SUCCESS", file);
        })
        .catch((err) => {
          console.log("RNFS mainPath ERROR", err);
        });

      RNFS.stat(cachaPath)
        .then((file) => {
          console.log("RNFS cachaPath SUCCESS", file);
        })
        .catch((err) => {
          console.log("RNFS cachaPath ERROR", err);
        });

      RNFS.stat(documentPath)
        .then((file) => {
          console.log("RNFS documentPath SUCCESS", file);
        })
        .catch((err) => {
          console.log("RNFS documentPath ERROR", err);
        });

      RNFS.stat(tmpPath)
        .then((file) => {
          console.log("RNFS tmpPath SUCCESS", file);
        })
        .catch((err) => {
          console.log("RNFS tmpPath ERROR", err);
        });

      // URL
      RNFetchBlob.fs.stat(url)
        .then((file) => {
          console.log("URL SUCCESS", file);
          file.path = url;
          //uploadFile(file);
        })
        .catch((err) => {
          console.log("URL => ERROR", err)
        });

      // MAIN
      RNFetchBlob.fs.stat(mainPath)
      .then((file) => {
        console.log("mainPath SUCCESS", file);
        file.path = url;
        //uploadFile(file);
      })
      .catch((err) => {
        console.log("mainPath => ERROR", err)
      });

      // CACHE
      RNFetchBlob.fs.stat(cachaPath)
        .then((file) => {
          console.log("cachaPath SUCCESS", file);
          file.path = url;
          //uploadFile(file);
        })
        .catch((err) => {
          console.log("cachaPath => ERROR", err)
        });

      // DOCUMENT
      RNFetchBlob.fs.stat(documentPath)
        .then((file) => {
          console.log("documentPath SUCCESS", file);
          file.path = url;
          //uploadFile(file);
        })
        .catch((err) => {
          console.log("documentPath => ERROR", err)
        });

      // TEMP
      RNFetchBlob.fs.stat(tmpPath)
        .then((file) => {
          console.log("tmpPath SUCCESS", tmpPath);
          file.path = url;
          //uploadFile(file);
        })
        .catch((err) => {
          console.log("tmpPath => ERROR", err)
        });
    }, 5000);
  }

please, point me in the right direction to make this work.

Thanks.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

21reactions
johuder33commented, Mar 17, 2017

Sure @sibelius , this is my solution code

I have a loadFileStatFromURL function to get stat info of the file and then upload to the server with some of the metadata that stat can give me, like size, type, lastModified, etc.

I always use decodeURIComponent function to decode the url that comes from document picker.

const loadFileStatFromURL = (url) => {
  const urlDecoded = decodeURIComponent(url);
  return new Promise((resolve, reject) => {
    RNFetchBlob.fs.stat(urlDecoded)
      .then(resolve)
      .catch(reject);
  });
};
3reactions
hzuleocommented, Sep 30, 2017

@johuder33 hi, i follow your code to do, but it is not work for me, can you post detailed code? or a link of demo?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error trying load files from iCloud, Dropbox #25 - GitHub
I've been using your module, quite good, but I face an issue with it. when trying load files from iCloud or Dropbox, the...
Read more >
Fix syncing problems in Dropbox
1. On your computer, click the Apple menu (Apple icon) in the top left corner of your screen. 2. Click System Preferences. 3....
Read more >
Types Of File Preview Errors And How To Handle Them
Have you encountered an error message while trying to preview a file in your Dropbox? Read on to learn how to handle every...
Read more >
Can't upload documents file to dropbox - … - Apple Community
I'm trying to upload my documents folder from my MacBook Pro to dropbox. Each time I get an error dialog (pic) saying "Error...
Read more >
Unable to access Dropbox via Files App on Apple iPad
My husband is unable to access Dropbox via the 'Files' App on his Apple iPad. This appears to be since the latest Dropbox...
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