将文件从GCS复制到云端硬盘

时间:2018-05-18 07:30:25

标签: node.js firebase google-drive-api google-cloud-storage google-cloud-functions

我编写了一个节点功能,可以从Google云端存储中读取文件并将其复制到Google云端硬盘。它能够连接到GCS并创建文件引用,但在发送到Drive时失败。

错误消息在EOF&#34之后显示" NodeError:stream.push();

这是相关的代码段。

const file = bucket.file(fileName);

const fileMetadata = {
    'name': fileName
};

const readStream = file.createReadStream();

const media = {
    mimeType: "image/png",
    body: readStream
};

drive
    .files
    .create({
        resource: fileMetadata,
        media: media,
        fields: 'id'
    }, function (err, file) {
        if (err) {
            console.log('error', err)
        } 
    });

0 个答案:

没有答案
相关问题