Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function getFile(options, fileName, toStoreName, log, callback) {
if (options.accessToken) {
// copy file to options.backupDir
const dropboxV2Api = require('dropbox-v2-api');
const dbx = dropboxV2Api.authenticate({token: options.accessToken});
let dir = (options.dir || '').replace(/\\/g, '/');
if (options.ownDir === true) {
dir = (options.dirMinimal || '').replace(/\\/g, '/');
}
if (!dir || dir[0] !== '/') {
dir = '/' + (dir || '');
}
try {
log.debug('Download of "' + fileName + '" started');
dbx({
resource: 'files/download',
parameters: {
'use strict';
const AWS = require('aws-sdk');
const dropboxV2Api = require('dropbox-v2-api');
const util = require('util');
var fs = require('fs');
var request = require("request");
var dropbox_token = process.env['DROPBOX_TOKEN'];
var media_bucket = process.env['MEDIA_BUCKET'];
// var ffmpeg = require('fluent-ffmpeg');
const dropbox = dropboxV2Api.authenticate({
token: dropbox_token
});
const videoOutput = '/tmp/file.mp4'
const mainOutput = '/tmp/output.mp4'
const dbfile = 'file.mp4'
var maxdata = 1048576000 // default max data limit - this is deliberately set to 1000MB rather than 1 Gig to allow headroom for settings.js transfers plus any other skills running
var datachargerate = 0.090 // this is the AWS Data transfer charge per Gigabyte first 10 TB / month data transfer out beyond the global free tier
process.env['PATH'] = process.env['PATH'] + ':' + process.env['LAMBDA_TASK_ROOT'];
var maxresults = 10;
var partsize = 60*5; // size of the video chunks in seconds
var settings = new Object();
var streamURL;
function command(options, log, callback) {
if (options.accessToken && options.context.fileNames.length) {
const fileNames = JSON.parse(JSON.stringify(options.context.fileNames));
const dropboxV2Api = require('dropbox-v2-api');
const dbx = dropboxV2Api.authenticate({token: options.accessToken});
let dir = (options.dir || '').replace(/\\/g, '/');
if (!dir || dir[0] !== '/') {
dir = '/' + (dir || '');
}
copyFiles(dbx, dir, fileNames, log, options.context.errors, err => {
if (err) {
options.context.errors.dropbox = err;
log.error(err);
}
if (options.deleteOldBackup === true) {
cleanFiles(dbx, dir, options.context.types, options.deleteBackupAfter, log, options.context.errors, err => {
if (err) {
options.context.errors.dropbox = options.context.errors.dropbox || err;
function list(restoreSource, options, types, log, callback) {
if (options.accessToken && (!restoreSource || restoreSource === 'dropbox')) {
const dropboxV2Api = require('dropbox-v2-api');
const dbx = dropboxV2Api.authenticate({token: options.accessToken});
let dir = (options.dir || '').replace(/\\/g, '/');
if (options.ownDir === true) {
dir = (options.dirMinimal || '').replace(/\\/g, '/');
}
if (!dir || dir[0] !== '/') {
dir = '/' + (dir || '');
}
try {
dbx({
resource: 'files/list_folder',
parameters: {
path: dir.replace(/^\/$/, '')