Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function saveMedia (opts, type, API) {
const { status } = await askAsyncPermissions(Permissions.CAMERA_ROLL)
if (status !== 'granted') {
const res = { errMsg: 'Permissions denied!' }
return Promise.reject(res)
}
const { filePath, success, fail, complete } = opts
const res = { errMsg: `${API}:ok` }
return CameraRoll.saveToCameraRoll(filePath, type)
.then((url) => {
res.path = url
success && success(res)
complete && complete(res)
return Promise.resolve(res)
}).catch((err) => {
res.errMsg = err.message
fail && fail(res)