How can I save a file from JS app to iCloud?

911 views Asked by At

Does iCloud provide anything like the google drive's "save to drive" button or dropbox's "saver"?

Or what is the easiest way to save a file (e.g. .pdf) from my app (JS/React) to iCloud? Thanks a lot!

1

There are 1 answers

0
iLuvLogix On

As mentioned in my comment you could use RNCloudFs.copyToCloud to copy files to the iCloud

Example:

const source = {uri: 'https://example.com/foobar.pdf'};
const destination = "/dox/foobar.pdf";
const mimeType = null;
const scope = 'visible';

RNCloudFs.copyToCloud({
  sourcePath: source, 
  targetPath: destination, 
  mimeType: mimeType, 
  scope: scope
})
.then((path) => {
  console.log("File transfer to: ", path, " was successful");
})
.catch((err) => {
  console.warn("File transfer failed with error: ", err);
})