【发布时间】:2018-01-17 06:18:54
【问题描述】:
function listFiles(auth) {
var service = google.drive('v3');
var fileMetadata = {
name: 'My Report4'
// mimeType: 'text/plain'
// 'mimeType': 'application/vnd.google-apps.spreadsheet'
};
var media = {
mimeType: 'text/plain',
body: fs.createReadStream('photo4.txt')
};
service.files.create({
auth: auth,
resource: fileMetadata,
media: media,
fields: 'id'
}, function (err, file) {
if (err) {
// Handle error
console.error(err);
} else {
console.log('File Id:', file.id);
}
});
}
error :{ [Error: socket hang up] code: 'ECONNRESET' } .
我认为问题出在正文中:fs.createReadStream('photo4.txt');
如果我将其更改为body : 'ANy text',它将起作用。
【问题讨论】:
标签: javascript google-drive-api google-api-js-client