Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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)
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')
}
}
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)
}
}
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;
}
render() {
const { photo, name, score, connectionDate, style } = this.props;
return (
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}`)
}
}
}
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)
}
})
}