How to use the follow-redirects.maxBodyLength function in follow-redirects

To help you get started, we’ve selected a few follow-redirects 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 expo / xdl / src / Api.js View on Github external
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}`;
github mzwallace / dw-cli / lib / write.js View on Github external
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
      },