【发布时间】:2021-10-01 22:36:06
【问题描述】:
当尝试将流上传到 Google 存储桶时,我在使用 get 方法时收到 Error: Not Found,在使用 request 方法时延迟几秒钟后收到 Error: socket hang up。
使用 firebase 的所有内容似乎都初始化得很好,当我记录流时,我看到数据通过了,但是使用远程 URL 将文件写入 GCS 的最佳方法是什么?
const storage = firebase.storage()
const bucket = storage.bucket("bucket/path")
const file = bucket.file("filename.pdf")
const url =
"https://url/to/file/filename.pdf"
https.get(url, async (res) => {
console.log(res)
res.pipe(file.createWriteStream())
})
【问题讨论】:
-
storage.bucket("bucket/path"):存储桶没有(目录)路径。路径是对象名称的一部分。 -
@JohnHanley 谢谢,这就是问题所在。将文件夹路径移动到文件中修复它
-
发布您的解决方案的答案,以便问题得到解决。
-
@JohnHanley 刚刚做了,谢谢!
标签: javascript node.js firebase google-cloud-storage firebase-storage