如何将文件从JS应用保存到iCloud?

问题描述

iCloud是否提供类似于Google驱动器的“ save to drive”按钮或投寄箱的“ saver”之类的东西?

或者将文件(例如.pdf)从我的应用程序(JS / React)保存到iCloud的最简单方法是什么? 非常感谢!

解决方法

如我的评论中所述,您可以使用RNCloudFs.copyToCloud将文件复制到iCloud

示例:

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);
})