Tag: 谷歌云存储

从Google云端存储中读取图片,并使用Google云端function进行发送

我想执行以下操作:创buildGoogle Cloud Function(http触发),只需从存储桶中读取图像文件(Google Cloud Storage)并将其作为响应发送。 我试过一些组合,我认为它应该是这样的: 'use strict'; const gcs = require('@google-cloud/storage')(); exports.sendImage = function sendImage(req, res) { let bucket = gcs.bucket('my-bucket-name'); let myImage = bucket.file('my-image-file.jpg'); res.contentType('image/jpeg'); res.end(myImage, 'binary'); }; 上面的function部署成功,但是当我触发它只是使用url(在浏览器),它没有显示任何结果。 我尽可能简单地做到这一点,因为如果它与一个图像一起工作,我可以改进代码来调用任何图像。 我的最终目标是在此post中显示类似的内容: https : //medium.com/google-cloud/uploading-resizing-and-serving-images-with-google-cloud-platform-ca9631a2c556 但在Google Cloud Functions上运行。 如果我设法发送一个简单的图像,我可以使用一些模块,如node-image-resize到最终结果。

Google云应用引擎重启function无法正常工作

由于某些原因,我们已经设置了节点应用程序。 现在我们要通过使用应用程序引擎中的设置页面来启用它 在这里input图像说明 但问题是当我们点击启用应用程序。 它说,应用程序正在启动…但又进入禁用状态,没有任何错误。 请帮助,如果我失去了什么

validation文件后,Google云404已存在

我有另一个项目,这个相同的代码工作成功,所以这可能是一些configuration选项,我错过了这一次。 我正在使用谷歌云API来访问Firebase存储。 为了清楚起见,该文件确实存在。 var storage = require('@google-cloud/storage')({ keyFilename: 'serviceAccountKey.json', projectId: 'my-id' }); var bucket = storage.bucket('my-id.appspot.com'); var file = bucket.file('directory/file.json'); //this exists! file.exists(function(err, exists){ console.log("Checking for challenges file. Results:" + exists + ", err:" + err); //returns "Checking for challenges file. Results:true, err:nil" if (exists) { console.log("File exists. Printing."); //prints "File exists. Printing." file.download().then(function(currentFileData) { […]

在通过file.createWriteStream()传输到GCP时,获取ESOCKETTIMEOUT,ECONNRESET或套接字会挂载大文件。

在尝试通过Google云端function将大文件(> 50MB)上传到Google云端存储时,根据我设置的选项,我遇到了这些例外: 当设置请求选项'永远:错误'我得到:错误:套接字挂断 当设置请求选项'resumable:true'时,我得到:Error:write ECONNRESET 当设置请求选项“可恢复:错误”我得到:错误:ESOCKETTIMEDOUT可恢复:假 这是我使用的代码: function uploadFile(bucketName, filename, data) { console.log("Starting uploading blob…"); const Storage = require('@google-cloud/storage'); console.log("Creating client…"); const storage = new Storage(); storage.interceptors.push({ request: function(reqOpts) { reqOpts.forever = false; return reqOpts } }); console.log("Getting bucket " + bucketName + "…"); const bucket = storage.bucket(bucketName); console.log("Creating file " + filename + "…"); […]

同样的Google云端存储上传脚本可以在一台电脑上运行,但是不能运行,为什么?

我试图用Node.JS(使用gcloud软件包)将file upload到Google云端存储,并获得服务帐户凭据,并且出现“invalid_grant”错误(可能是授权错误)。 当我尝试从另一台电脑上做到这一点 – 它工作正常,错误只发生在我的电脑上。 var gcloud = require('gcloud')({ projectId: 'xxxxxxxxxxxxxx31032015', keyFilename: './keyfile.json' }); var storage = gcloud.storage(); var bucket = storage.bucket('test.testBucket.com'); bucket.upload('test.png', function (err, file) { console.log(err); });

如何从服务器上的客户端JavaScript上载到Google云端存储?

我想直接从我的客户端JavaScript代码上传到Google云端存储存储分区,尽pipe存储分区不应公开写入。 服务器端代码是Node.js. 在过去,我可以通过为服务器上的客户端生成临时授权,直接上传到Amazon S3。 上传文件到写保护的Google云存储存储分区的过程是什么?

通过GAE托pipe的node.js express服务器上传大文件

我需要通过我在Google App Engine中托pipe的节点服务器上传大型文件(超过300 MB)。 我能够使用xhr.upload上传文件,并且在本地工作正常,但是在GAE中,我得到了413 – 请求实体太大了 ,GAE似乎对内容大小有32MB的限制。 在探索的过程中,我遇到了谷歌BlobStore API,但似乎并不支持NodeJS。 你们可以请build议我哪个是最好的方法呢? 提前致谢。

使用NodeJS在本地上传文件到Google Cloud存储

我正尝试使用我的服务帐户在本地计算机上使用简单代码将图像上传到Google云端存储: const storage = require('@google-cloud/storage'); const fs = require('fs'); const gcs = storage({ projectId: 'ID', keyFilename: 'KEYNAME' }); var bucket = gcs.bucket('BUCKET NAME'); bucket.upload('hiking-image.jpg', function(err, file) { if (err) throw new Error(err); }); if (err) throw new Error(err); ^ 但是,我收到下面的错误消息。 Google Cloud API只能在App Engine上部署时才能工作,还是我在这里做错了? 我能够让Google Vision API使用同一个服务帐户在本地工作。 Error: ApiError: Forbidden at /Users/user/google-cloud/upload/upload.js:10:20 at Pumpify.<anonymous> (/Users/user/node_modules/@google-cloud/storage/src/bucket.js:1218:9) […]

Node.js Google云存储上传目标规范

我有一个Node.js服务器,我正在使用google-cloud软件包将一些图像file upload到Firebase存储 。 上传本身工作正常,但谷歌云API似乎只能上传文件到Firebase存储根文件夹。 有什么办法指定远程位置上传图像? 我现在在做什么: const serviceAccount = require('./serviceAccount.json'); const storage = gcloud.storage({ projectId: '*projectId*', credentials: serviceAccount }); const storageBucket = storage.bucket('*bucket*'); storageBucket.upload(localFsPath) .then(data => /* Some stuff */) .catch(err => console.log(err)); 有没有办法做这样的事情? storageBucket.upload(path, { destination: 'a/b/c/file.jpg' }) .then(data => /* Some stuff */) .catch(err => console.log(err));

谷歌云存储对象删除谷歌API,Node.js和request.del()

正如标题所说,我目前正在尝试使用请求和google_API删除一个对象。 但是, 即使我做了Google Cloud Platform所说的, 它不起作用。 请帮帮我。 我该怎么办?