part.body.pipe is not a function
See original GitHub issueEnvironment details
- OS: Linux
- Node.js version: 12.9.0
- npm version: 6.11.2
googleapisversion: 43.0.0
Steps to reproduce
I have the following piece of code:
const drive = google.drive({
version: 'v3',
auth: 'MYAPIKEYHERE'
});
const folderId = 'MYFOLDERIDHERE';
const fileMetadata = {
name: filename,
parents: [ folderId ]
};
const media = {
body: file
};
return new Promise((resolve, reject) => {
drive.files.create({
// @ts-ignore
resource: fileMetadata,
media: media,
fields: 'id'
// @ts-ignore
}, (err, result) => {
if (null !== err) {
reject(err);
} else {
resolve(result.id);
}
});
});
filename is a string and file a Buffer… I tried many combinations from StackOverflow, Github, and Google Docs but all of them gave me the following error:
TypeError: part.body.pipe is not a function
at createAPIRequestAsync (/home/farm/Documents/InventorySystemAPI/node_modules/googleapis-common/build/src/apirequest.js:182:31)
at Object.createAPIRequest (/home/farm/Documents/InventorySystemAPI/node_modules/googleapis-common/build/src/apirequest.js:41:9)
at Resource$Files.create (/home/farm/Documents/InventorySystemAPI/node_modules/googleapis/build/src/apis/drive/v3.js:660:37)
at /home/farm/Documents/InventorySystemAPI/dist/google/drive.js:39:21
at new Promise (<anonymous>)
at Object.<anonymous> (/home/farm/Documents/InventorySystemAPI/dist/google/drive.js:38:12)
at Generator.next (<anonymous>)
at /home/farm/Documents/InventorySystemAPI/dist/google/drive.js:7:71
at new Promise (<anonymous>)
at __awaiter (/home/farm/Documents/InventorySystemAPI/dist/google/drive.js:3:12)
at Object.exports.addToGDrive (/home/farm/Documents/InventorySystemAPI/dist/google/drive.js:13:43)
at Object.<anonymous> (/home/farm/Documents/InventorySystemAPI/dist/controllers/invoice.js:21:44)
at Generator.next (<anonymous>)
at /home/farm/Documents/InventorySystemAPI/dist/controllers/invoice.js:7:71
at new Promise (<anonymous>)
at __awaiter (/home/farm/Documents/InventorySystemAPI/dist/controllers/invoice.js:3:12)
The funny part is that following the Google Docs tutorial when I tried to create a ‘credntials.json’ file, it was given to me an API key.
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
TypeError: undefined is not a function at pipe in nodejs
Try this: request({ method: "GET", "rejectUnauthorized": false, "url": url, "headers" : {"Content-Type": "application/json", ...
Read more >How to solve the "is not a function" error in JavaScript
js we use require() to load external modules and files. This can cause, in some cases, an error like this: TypeError: require(...) is...
Read more >Stream | Node.js v19.3.0 Documentation
pipe () method, is to limit the buffering of data to acceptable levels such that sources and destinations of differing speeds will not...
Read more >Node.js
The example does not use write because GET requests should not contain data in their request body. There's a similar request function in...
Read more >javascript axios response.data.pipe not a function
... response.data.pipe not a function. Add Answer | View In TPC Matrix. Technical Problem Cluster First Answered On May 10, 2022 Popularity 3/10...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi, Fazendaaa seems the body key only accepts a readable stream so.
const { Readable } = require('stream')…body: Readable.from(file)Hope this helps someone
@Fazendaaa @rashikbhasin rather than using a
Buffer, could you try passing:☝️ I believe this is the API surface that it expects currently (I understand wanting to pass a buffer, this might be a feature request or gap in documentation).