Failed export googledocs : This file is too large to be exported.
Maintainers usually reply within 2 days
@sofisl is already working on this.
Since Apr 4, 2024.
Assessment
This issue has not been assessed yet.
Description
Thanks for stopping by to let us know something could be better!
PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.
-
Is this a client library issue or a product issue?
This is the client library for . We will only be able to assist with issues that pertain to the behaviors of this library. If the issue you're experiencing is due to the behavior of the product itself, please visit the Support page to reach the most relevant engineers. -
Did someone already solve this?
- Search the issues already opened: https://github.com/googleapis/google-api-nodejs-client/issues
- Search the issues on our "catch-all" repository: https://github.com/googleapis/google-cloud-node
- Search or ask on StackOverflow (engineers monitor these tags): http://stackoverflow.com/questions/tagged/google-cloud-platform+node.js
- Do you have a support contract?
Please create an issue in the support console to ensure a timely response.
If the support paths suggested above still do not result in a resolution, please provide the following details.
Environment details
- OS: MacOs
- Node.js version: v18.16.1
- npm version:9.8.1
googleapisversion: 133.0.0
import { readFileSync } from 'fs';
import { google } from 'googleapis';
import path from 'path';
import { Readable } from 'stream';
export const bufferToStream = (buffer: Buffer): Readable => {
const stream = new Readable();
stream.push(buffer);
stream.push(null);
return stream;
};
export const createEmptyStream = (): Readable => {
const stream = new Readable();
stream._read = () => {};
stream.push(null);
return stream;
};
export async function downloadPDFDoc(fileId: string): Promise<Buffer> {
try {
const KEYFILEPATH = path.join(__dirname, 'happyhomes-360410-4644e17e212c.json');
const credentials = JSON.parse(readFileSync(KEYFILEPATH, 'utf8'));
const auth = new google.auth.GoogleAuth({
credentials,
scopes: ['https://www.googleapis.com/auth/drive'],
});
const drive = google.drive({
version: 'v3',
auth,
});
const response = await drive.files.export(
{
fileId: fileId,
mimeType: 'application/pdf',
},
{ responseType: 'stream' },
);
return new Promise((resolve, reject) => {
const chunks: Buffer[] = [];
response.data.on('data', (chunk: Buffer) => {
chunks.push(chunk);
});
response.data.on('end', () => {
console.log('File download completed.');
resolve(Buffer.concat(chunks));
});
response.data.on('error', (err: Error) => {
console.error('Error downloading file:', err);
reject(err);
});
});
} catch (error) {
console.error('The API returned an error: ' + error);
throw error;
}
}```
The total documents I exported were 18 MB, and when I ran this service, I got this error
```js GaxiosError: {
"error": {
"code": 400,
"message": "This file is too large to be exported.",
"errors": [
{
"message": "This file is too large to be exported.",
"domain": "global",
"reason": "badRequest",
"location": "export.size",
"locationType": "other"
}
]
}
}
at Gaxios._request (/Users/sonisuciadi/Happyhomes/rem-be/node_modules/gaxios/src/gaxios.ts:174:15)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at JWT.requestAsync (/Users/sonisuciadi/Happyhomes/rem-be/node_modules/google-auth-library/build/src/auth/oauth2client.js:405:18)
at downloadPDFDoc (/Users/sonisuciadi/Happyhomes/rem-be/src/helpers/google-docs/downloadPDFDoc.ts:57:26)
at publishOfferDocController (/Users/sonisuciadi/Happyhomes/rem-be/src/controllers/project/procurement/procurementDetailOutputJob.controllers.ts:241:32) {
config: {
url: 'https://www.googleapis.com/drive/v2/files/1G11FllbKw6qLbYJM1N8TdZpb6G2Q4QazslxsgLw9oO4/export?mimeType=application%2Fpdf',
method: 'GET',
responseType: 'stream',
userAgentDirectives: [ [Object] ],
paramsSerializer: [Function (anonymous)],
headers: {
'x-goog-api-client': 'gdcl/7.0.1 gl-node/20.6.1',
'Accept-Encoding': 'gzip',
'User-Agent': 'google-api-nodejs-client/7.0.1 (gzip)',
Authorization: 'Bearer ya29.c.c0AY_VpZi_y24RI-304tmmNmbUcghDfre0a7qnssZ_nX1xamM7YfmaxWHscd6djR88HBzBzgCLjEQLOqc_GDrGloS3jqaEMa6Pa7_R3InWNRhP8lYdjVKt5_WmFhmfeq7R9rQsLn804hB34_T1o82bW2GecegBaPF0MeDJvoAOMv-xEqb21cOUC4rBdqo-jDWGu0wrwx0otC0UBDfbRbhsrlKV75Yoe204NouUWSaEjJiMRgzOskPb2fmbDMEkTKAgsfk1J2teFrpXhbgGi4M3kStpRgAG2H8cUhTyE9ubcwcT62oIgvG3Rldfa6y0-5A04HyXR1jtHweJsFCL57zJ4jgRNICEOi6A_l1s16EaUYIk3W0CWSXpuaIE384PUel96bBbc4iO3XRimlOpYSXtorulM795V0zauSrp_wrqUozQ2UOstJMF7o8l204ei39jeFFwpI2BM_xlh54ROWt6mbwwY312qeB50aWz0M3wvxddqu3a_20x-zyokwhpMmh0fbm40IIOaFa-Y1B834BY6aUfyQwSRZq6UfO0kUyoWMah1ywmkqMV9kz75ta6ekSnY0QwroMQYbId31dMOWZuaOcaZV9Ok9OdxapZM8B1d8U-QuXORsJv_fa6IdYUgdjwz4rwFkJiM6_zSfkU200urFzOphvcdVkYoppW7mr67rSBznrwqYI0677FtJUqthfnrtJ_ZJpo-t9ougguffaQipJwjFwZmyfoS1fOubfzqatBVnurW87R2B-JlY997ob3bffMZISuQ27MXt9JM5hfYgbyRns39g57m4v6ktVOBvVq7am8w-wqse7kbi0QIa5JjYBoeetzbMu454uev27UZiumv9kIMVFo0e9kp1V-wfXqIymj-74ybm9JyQ8wmqckcI8s9O9q5hXJ2nop_9iR_tj5QqsBmSnZtlBY57MleSsgy_IXW5ktzjez9Rw2SjakQ_i0xl6pi7wZ3q5mX8o2F45vj2Mo7woJB-BhpVcvScq0Fqbv9iavFF7'
},
params: { mimeType: 'application/pdf' },
validateStatus: [Function (anonymous)],
retry: true,
errorRedactor: [Function: defaultErrorRedactor],
retryConfig: {
currentRetryAttempt: 0,
retry: 3,
httpMethodsToRetry: [Array],
noResponseRetries: 2,
statusCodesToRetry: [Array]
}
},
response: {
config: {
url: 'https://www.googleapis.com/drive/v2/files/1G11FllbKw6qLbYJM1N8TdZpb6G2Q4QazslxsgLw9oO4/export?mimeType=application%2Fpdf',
method: 'GET',
responseType: 'stream',
userAgentDirectives: [Array],
paramsSerializer: [Function (anonymous)],
headers: [Object],
params: [Object],
validateStatus: [Function (anonymous)],
retry: true,
errorRedactor: [Function: defaultErrorRedactor]
},
data: '{\n' +
' "error": {\n' +
' "code": 400,\n' +
' "message": "This file is too large to be exported.",\n' +
' "errors": [\n' +
' {\n' +
' "message": "This file is too large to be exported.",\n' +
' "domain": "global",\n' +
' "reason": "badRequest",\n' +
' "location": "export.size",\n' +
' "locationType": "other"\n' +
' }\n' +
' ]\n' +
' }\n' +
'}\n',
headers: {
'alt-svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000',
'cache-control': 'private, max-age=0',
'content-length': '321',
'content-type': 'application/json; charset=UTF-8',
date: 'Wed, 28 Feb 2024 16:28:46 GMT',
expires: 'Wed, 28 Feb 2024 16:28:46 GMT',
server: 'ESF',
vary: 'Origin, X-Origin',
'x-content-type-options': 'nosniff',
'x-frame-options': 'SAMEORIGIN',
'x-guploader-uploadid': 'ABPtcPqCOaSGjiUlM-J9pa8kUkAtcLeR4NDexI63N2ecZ7dCEkTryxssJKL7HmpIDi5QJWZyPp3eaFaUew',
'x-xss-protection': '0'
},
status: 400,
statusText: 'Bad Request',
request: {
responseURL: 'https://www.googleapis.com/drive/v2/files/1G11FllbKw6qLbYJM1N8TdZpb6G2Q4QazslxsgLw9oO4/export?mimeType=application%2Fpdf'
}
},
error: undefined,
status: 400,
[Symbol(gaxios-gaxios-error)]: '6.3.0'
}
Thanks!
- Dominant language
- TypeScript
- Stars
- 12.3k
- Forks
- 2k
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 9
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from googleapis/google-api-nodejs-client
-
Difficulty 1/5 Under an hour Newbie friendliness 86/100
googleapis/google-api-nodejs-client#4064 ·
Maintainers usually reply within 2 days
-
Difficulty 4/5 1-2 days Newbie friendliness 5/100
googleapis/google-api-nodejs-client#4067 ·
Maintainers usually reply within 2 days
-
Difficulty 5/5 Over a week Newbie friendliness 1/100
googleapis/google-api-nodejs-client#4063 ·
Maintainers usually reply within 2 days
-
eMudhra/emSign CA compromise (October 2026): what Cloud SDK Node.js Libraries developers need to doOpen
Difficulty 1/5 Under an hour Newbie friendliness 10/100
googleapis/google-api-nodejs-client#4062 ·
Maintainers usually reply within 2 days
-
Difficulty 5/5 Over a week Newbie friendliness 10/100
googleapis/google-api-nodejs-client#4061 ·
Maintainers usually reply within 2 days
All issues in googleapis/google-api-nodejs-client
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
pieterjanscheir/belgica#201 ·
Maintainers usually reply within 1 day
-
accessibility
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
numerique-gouv/lasuite-landingpage#311 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
oxc-project/tsgolint#1362 ·
Maintainers usually reply within 1 day
-
bug external xai
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
langchain-ai/langchain#41854 ·
Maintainers usually reply within 1 day
-
ready-for-agent
Difficulty 1/5 1-3 hours Newbie friendliness 72/100
nemchik/biome-plugin-suitescript#137 ·
Maintainers usually reply within 1 day