Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import path from 'path';
import axios from 'axios';
import followRedirects from 'follow-redirects';
import concat from 'concat-stream';
import { Cacher } from './tools/FsCache';
import Config from './Config';
import { isNode } from './tools/EnvironmentHelper';
import ErrorCode from './ErrorCode';
import * as Extract from './Extract';
import * as Session from './Session';
import UserManager from './User';
import UserSettings from './UserSettings';
import XDLError from './XDLError';
followRedirects.maxBodyLength = 50 * 1024 * 1024; // 50 MB
const TIMER_DURATION = 30000;
const TIMEOUT = 3600000;
function ApiError(code, message) {
let err = new Error(message);
// $FlowFixMe error has no property code
err.code = code;
// $FlowFixMe error has no property _isApiError
err._isApiError = true;
return err;
}
// These aren't constants because some commands switch between staging and prod
function _rootBaseUrl() {
return `${Config.api.scheme}://${Config.api.host}`;
const fs = require('fs-extra');
const path = require('path');
const debug = require('debug')('write');
const axios = require('axios');
const followRedirects = require('follow-redirects');
followRedirects.maxBodyLength = 100 * 1024 * 1024;
module.exports = (src, dest, options) => {
try {
debug(`Uploading ${src}`);
const url = path.join('/', dest, path.basename(src));
const stats = fs.statSync(src);
const stream = fs.createReadStream(src);
const config = Object.assign(
{
url,
method: 'put',
validateStatus: status => status < 400,
maxRedirects: 0
},