{"_id":"@1tokenfe/react-native-cloud-fs","name":"@1tokenfe/react-native-cloud-fs","dist-tags":{"latest":"2.6.3"},"versions":{"2.6.3":{"name":"@1tokenfe/react-native-cloud-fs","version":"2.6.3","description":"A react-native library for reading and writing files to _iCloud Drive_ (iOS) and _Google Drive_ (Android).","main":"index.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"keywords":["react-native"],"author":"","license":"","_id":"@1tokenfe/react-native-cloud-fs@2.6.3","gitHead":"feef3ae38065a344036fca0c26d1f4ab35dd719e","_nodeVersion":"22.17.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-sWJY9MQst+p16BcWvbdZ8EKLQ0E1/byzb560n/oyF74naBjS2fiSmfoelHg1xbmpR37wcIHqzJ0lalqMYwTLAA==","shasum":"1e8440e22e58f5f095744e0902c31f0a8d655010","tarball":"https://registry.npmjs.org/@1tokenfe/react-native-cloud-fs/-/react-native-cloud-fs-2.6.3.tgz","fileCount":23,"unpackedSize":209925,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCi6rD/39yWt8k6Kxly6KOndnycJgHODOX3WpPf8LghbwIhAK2GWX6T0lBeDJ1a+QCNsR+WGM4d8rJsaaGbNdjC/BN+"}]},"_npmUser":{"name":"vici1573","email":"vici1573@outlook.com"},"directories":{},"maintainers":[{"name":"vici1573","email":"vici1573@outlook.com"},{"name":"onetokenwallet","email":"yf860412@gmail.com"},{"name":"dihuase0411","email":"dihuase0411@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/react-native-cloud-fs_2.6.3_1763366755669_0.5877214940629374"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-17T08:05:55.533Z","2.6.3":"2025-11-17T08:05:55.887Z","modified":"2025-11-17T08:05:56.260Z"},"maintainers":[{"name":"vici1573","email":"vici1573@outlook.com"},{"name":"onetokenwallet","email":"yf860412@gmail.com"},{"name":"dihuase0411","email":"dihuase0411@gmail.com"}],"description":"A react-native library for reading and writing files to _iCloud Drive_ (iOS) and _Google Drive_ (Android).","keywords":["react-native"],"readme":"\n# react-native-cloud-fs\n\nA react-native library for reading and writing files to _iCloud Drive_ (iOS) and _Google Drive_ (Android).\n\n[Getting started](./docs/getting-started.md)\n\n## Usage\n```javascript\nimport RNCloudFs from 'react-native-cloud-fs';\n```\n\n### fileExists (options)\nReturns a promise which when resolved returns a boolean value indicating if the specified path already exists.\n\n```javascript\nconst destinationPath = \"foo-bar/docs/info.pdf\";\nconst scope = 'visible';\n\nRNCloudFs.fileExists({\n  targetPath: destinationPath, \n  scope: scope\n})\n  .then((exists) => {\n    console.log(exists ? \"this file exists\" : \"this file does not exist\");\n  })\n  .catch((err) => {\n    console.warn(\"it failed\", err);\n  })\n```\n_targetPath_: a path\n\n_scope_: determines if the user-visible documents (`visible`) or the app-visible documents (`hidden`) are searched for the specified path\n\n### copyToCloud (options)\nCopies the content of a file (or uri) to the target file system.  The files will appear in a either a user visible \ndirectory, or a dectory that only the app can see.  The directory is named after `destinationPath`.  The directory \nhierarchy for the destination path will be created if it doesn't already exist. If the target file already exists \nit a new filename is chosen and returned when the promise is resolved. \n\n```javascript\nconst sourceUri = {uri: 'https://foo.com/bar.pdf'};\nconst destinationPath = \"foo-bar/docs/info.pdf\";\nconst mimeType = null;\nconst scope = 'visible';\n\nRNCloudFs.copyToCloud({\n  sourcePath: sourceUri, \n  targetPath: destinationPath, \n  mimeType: mimeType, \n  scope: scope\n})\n  .then((path) => {\n    console.log(\"it worked\", path);\n  })\n  .catch((err) => {\n    console.warn(\"it failed\", err);\n  })\n```\n\n_sourceUri_: object with any uri or an **absolute** file path and optional http headers, e.g:\n * `{path: '/foo/bar/file.txt'}`\n * `{uri: 'file://foo/bar/file.txt'}`\n * `{uri: 'http://www.files.com/foo/bar/file.txt', 'http-headers': {user: 'foo', password: 'bar'}}` (http-headers are android only)\n * `{uri: 'content://media/external/images/media/296'}` (android only)\n * `{uri: 'assets-library://asset/asset.JPG?id=106E99A1-4F6A-45A2-B320-B0AD4A8E8473&ext=JPG'}` (iOS only)\n \n_targetPath_: a **relative** path including a filename under which the file will be placed, e.g:\n * `my-cloud-text-file.txt`\n * `foo/bar/my-cloud-text-file.txt`\n \n_mimeType_:  a mime type to store the file with **or null** (android only) , e.g:\n * `text/plain`\n * `application/json`\n * `image/jpeg`\n\n_scope_: a string to specify if the user can access the document (`visible`) or not (`hidden`)\n\n### listFiles (options)\nLists files in a directory along with some file metadata.  The scope determines if the file listing takes place in the app folder or the public user documents folder.\n\n```javascript\nconst path = \"dirA/dirB\";\nconst scope = 'hidden';\n\nRNCloudFs.listFiles({targetPath: path, scope: scope})\n  .then((res) => {\n    console.log(\"it worked\", res);\n  })\n  .catch((err) => {\n    console.warn(\"it failed\", err);\n  })\n```\n\n_targetPath_: a path representing a folder to list files from\n\n_scope_: a string to specify if the files are the user-visible documents (`visible`) or the app-visible documents (`hidden`)\n\n\n## Android\n\nAfter following the instructions in [Getting started](./docs/getting-started.md) I recommend using [react-native-google-signin](https://github.com/react-native-google-signin/google-signin) to authenticate the user, especially if you need additional scopes besides `auth/drive.file` which is the only scope this package requests, and let that package handle auth.\n\nExample of usage on Android:\n\n```js\nimport { Platform } from 'react-native';\nimport { GoogleSignin, statusCodes } from '@react-native-community/google-signin';\nimport RNCloudFS from 'react-native-cloud-fs';\n\nif (Platform.OS === 'android') {\n  GoogleSignin.configure({\n    scopes: [\n      'https://www.googleapis.com/auth/userinfo.profile',\n      'https://www.googleapis.com/auth/userinfo.email',\n      'https://www.googleapis.com/auth/drive.file',\n      // other scopes your app needs\n    ],\n    webClientId: '...' // you may not need this depending on scopes,\n    offlineAccess: true,\n    forceConsentPrompt: true,\n  });\n\n  // Ensure play services exist. Cannot sign in otherwise. If unavailable, this\n  // will show a modal asking the user to get play services before continuing.\n  await GoogleSignin.hasPlayServices({\n    showPlayServicesUpdateDialog: true\n  });\n\n  // If user is already signed in, don't need to call signIn again\n  const isSignedIn = await GoogleSignin.isSignedIn();\n  if (!isSignedIn) {\n    await GoogleSignin.signIn();\n  }\n\n  // Syncs signed in state to RNCloudFS\n  await RNCloudFS.loginIfNeeded();\n  \n  // Now you can copy to cloud\n  await RNCloudFS.copyToCloud({\n    sourcePath: { path: 'some/path.txt' },\n    targetPath: `some/path.txt`,\n    scope: 'visible'\n  });\n}\n```\n","readmeFilename":"README.md","_rev":"1-bf8e9449230361f886c9013917fa0d86"}