Skip to content

Commit

Permalink
fix: raise default of maxContentLength (#1016)
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeckwith committed Feb 23, 2018
1 parent 5d10a27 commit 6f684c2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/lib/apirequest.ts
Expand Up @@ -21,6 +21,8 @@ import * as uuid from 'uuid';
import {APIRequestParams} from './api';
import {SchemaParameters} from './schema';

const maxContentLength = Math.pow(2, 31);

function isReadableStream(obj: stream.Readable|string) {
return obj instanceof stream.Readable && typeof obj._read === 'function';
}
Expand Down Expand Up @@ -190,6 +192,10 @@ export function createAPIRequest<T>(

options.headers = headers;
options.params = params;
// We need to set a default content size, or the max defaults
// to 10MB. Setting to 2GB by default.
// https://github.com/google/google-api-nodejs-client/issues/991
options.maxContentLength = options.maxContentLength || maxContentLength;

// Combine the AxiosRequestConfig options passed with this specific
// API call witht the global options configured at the API Context
Expand Down
1 change: 1 addition & 0 deletions test/test.media.ts
Expand Up @@ -54,6 +54,7 @@ async function testMediaBody(drive: APIEndpoint) {
{encoding: 'utf8'});
const res = await pify(drive.files.insert)({resource, media});
assert.equal(res.config.method.toLowerCase(), 'post');
assert.equal(res.config.maxContentLength, Math.pow(2, 31));
assert.equal(res.request.path, '/upload/drive/v2/files?uploadType=multipart');
assert.equal(
res.request.headers['content-type'].indexOf('multipart/related;'), 0);
Expand Down

0 comments on commit 6f684c2

Please sign in to comment.