How to use the react-native-fs.DocumentDirectoryPath function in react-native-fs

To help you get started, we’ve selected a few react-native-fs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github smallpath / psnine / psnine / component / ImageViewer / index.ios.tsx View on Github external
import React from 'react'

import fs from 'react-native-fs'
import ImageViewer from 'react-native-image-zoom-viewer'
import {
  Animated,
  Easing,
  CameraRoll
} from 'react-native'

declare var global

const psnineFolder = fs.DocumentDirectoryPath + '/psnine'

fs.stat(psnineFolder).then(data => {
  const isDirectory = data.isDirectory()
  if (!isDirectory) {
    fs.unlink(psnineFolder).catch(() => {}).then(() => fs.mkdir(psnineFolder))
  }
}).catch(() => {
  fs.mkdir(psnineFolder).catch(err => console.log(err, 'ImageViewer:line#27'))
})

const onSave = (image) => {
  // console.log(image, psnineFolder + '/' + image.split('/').pop())
  const result = CameraRoll.saveToCameraRoll(image)
  return result.then((url) => {
    global.toast('保存成功')
    return url
github textileio / photos / App / Services / PhotosTask.js View on Github external
export default async function photosTask (dispatch, failedImages) {
  // console.log('FAILED IMAGES:', failedImages)
  console.log('running photos task')
  BackgroundTimer.start() // This requests some background time from the OS

  // Start IPFS
  const path = RNFS.DocumentDirectoryPath
  await IPFS.createNodeWithDataDir(path)
  await IPFS.startNode()

  // Get a list of the jobs already in the queue
  // const existingJobs = await queue.getJobs(true)

  // Query for any new photos, add jobs to queue
  const photos = await queryPhotos()
  // PushNotificationIOS.presentLocalNotification({
  //   alertBody: 'fetch of ' + photos.length + ' photos',
  //   userInfo: {}
  // })
  for (const photo of photos) {
    const multipartData = await IPFS.addImageAtPath(photo.node.image.path, photo.node.image.thumbPath)
    await RNFS.unlink(photo.node.image.path)
    await RNFS.unlink(photo.node.image.thumbPath)
github berty / berty / js / packages / components / debug / AppInspector.tsx View on Github external
const getRootDir = () => {
	switch (Platform.OS) {
		case 'ios': // Check GoBridge.swift
		case 'android': // Check GoBridgeModule.java
			return RNFS.DocumentDirectoryPath + '/berty'

		default:
			throw new Error('unsupported platform')
	}
}
github airsecure / airsecure / src / Sagas / MainSagas.ts View on Github external
export function * parseNewCode(action: ActionType) {
  const appThread = yield select(MainSelectors.getAppThread)

  const url = parseUrl(action.payload.url, true)
  const label = url.pathname.slice(1).split(':')
  const file = url.query
  file['user'] = label[1]
  file['type'] = url.host

  const path = RNFS.DocumentDirectoryPath + '/' + fakeUUID() + '.json'
  try {
   yield call(RNFS.writeFile, path, JSON.stringify(file), 'utf8')
   const result = yield call(Textile.prepareFilesAsync, path, appThread.id)
   yield call(RNFS.unlink, path)

   const dir = result.dir
   if (!dir) {
     return
   }
   yield call(Textile.addThreadFiles, dir, appThread.id)
   yield call(refreshThreads, appThread)
  } catch (err) {
    console.log("CODY ERR: " + err.message)
  }
}
github microsoft / appcenter-sdk-react-native / TestApp / app / AttachmentsProvider.js View on Github external
static async getBinaryAttachment() {
    const path = `${RNFS.DocumentDirectoryPath}/${BINARY_ATTACHMENT_STORAGE_FILENAME}`;
    let contents = '';
    try {
      contents = await RNFS.readFile(path, DEFAULT_ENCODING);
    } catch (error) {
      console.log(`Error while reading binary attachment file, error: ${error}`);
    }
    return contents;
  }
github BrightID / BrightID / BrightID / src / components / Recovery / RecoveringConnectionCard.js View on Github external
render() {
    const { photo, name, score, connectionDate, style } = this.props;

    return (
github textileio / photos / App / Sagas / NodeLifecycle.ts View on Github external
async function moveTextileFiles() {
  const files = await RNFS.readDir(RNFS.DocumentDirectoryPath)
  for (const file of files) {
    if (file.path !== REPO_PATH && file.name !== 'RCTAsyncLocalStorage_V1') {
      await RNFS.moveFile(file.path, `${REPO_PATH}/${file.name}`)
    }
  }
}
github celo-org / celo-monorepo / packages / mobile / src / qrcode / utils.ts View on Github external
svg.toDataURL(async (data: string) => {
    const path = RNFS.DocumentDirectoryPath + QRFileName
    try {
      await RNFS.writeFile(path, data, 'base64')
      Share.open({
        url: 'file://' + path,
        type: 'image/png',
      }).catch((err: Error) => {
        throw err
      })
    } catch (e) {
      Logger.warn(TAG, e)
    }
  })
}