Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google cloud storage 从HTTPS到Google云存储桶的流_Google Cloud Storage_Google Cloud Functions - Fatal编程技术网

Google cloud storage 从HTTPS到Google云存储桶的流

Google cloud storage 从HTTPS到Google云存储桶的流,google-cloud-storage,google-cloud-functions,Google Cloud Storage,Google Cloud Functions,是否可以将Google云函数中的fetchapi中的“ReadableStream”流式传输到bucket中 getReader()似乎从fetch的http响应返回一个。createReadStream和 createWriteStream(); localReadStream.pipe(remoteWriteStream) 假设将流从bucket=>fs=>fs传输到bucket(或不同bucket中的新文件),但AFAIK云函数不允许本地文件访问,对吗 一条流如何从一条流到一个桶?让它工作

是否可以将Google云函数中的
fetch
api中的“ReadableStream”流式传输到bucket中

getReader()似乎从fetch的http响应返回一个。createReadStream和
createWriteStream();
localReadStream.pipe(remoteWriteStream)

假设将流从bucket=>fs=>fs传输到bucket(或不同bucket中的新文件),但AFAIK云函数不允许本地文件访问,对吗

一条流如何从一条流到一个桶?

让它工作:

const fetch = require('node-fetch');
const Storage = require('@google-cloud/storage');
const CLOUD_BUCKET = 'MY_BUCKET_NAME'
const storage = Storage({
  projectId: 'MY_PROJECT_NAME'
});
const bucket = storage.bucket(CLOUD_BUCKET);
fetch(url).then( response => {
  let remoteWriteStream = bucket.file('zebra.png').createWriteStream();
  response.body.pipe(remoteWriteStream);
})
基本上是用管道将身体本身连接起来。

你看过吗?