我正在使用dev_appserver.py测试我的应用程序。
我上传文件的函数类似于:
def upload_file(file_stream, filename):
"""Upload a file to Google Cloud Storage."""
client = google.cloud.storage.client.Client(project=_GOOGLE_CLOUD_PROJECT)
bucket = client.get_bucket(_GOOGLE_STORAGE_BUCKET) # Here
我是上传多个图片在Picture(类似文件夹)下的谷歌云存储桶。
例如:Picture/a.jpg, Picture/b.jpg, Pictuer/c.jpg, .....
现在,我想将云存储中的多幅图像直接显示到我的cakephp 2.x web应用程序中作为一个列表。
根据Google文档,要访问桶中的每个对象,必须生成。因此,我根据从数据库中选择的数据为每个对象创建了签名URL。下面是我的示例代码。
<?php
# Imports the Google Cloud client library
use Google\Cloud\Storage\StorageClient;
use
我有以下代码:
bucket = get_bucket('bucket-name')
blob = bucket.blob(os.path.join(*pieces))
blob.upload_from_string('test')
blob.make_public()
result = blob.public_url
# result is `<Mock name='mock().get_bucket().blob().public_url`
我想要模拟public_url的结果,我的单元测试代码是这样的
with ExitStack() as
我想在python中创建一个函数,使用Google Cloud Storage Client Library函数帮助枚举元数据 我已经创建了列出存储桶的函数,我只想显示存储桶的元数据,如下所示https://cloud.google.com/storage/docs/json_api/v1/buckets#resource for bucket in self.client.list_buckets():
print(bucket)
# this list the all the buckets 我想要这样的东西 def meta(self):
上传文件到Google云存储后,我正在尝试获取永久(未签名)下载URL。我可以使用file.createWriteStream()获取已签名的下载URL,但file.createWriteStream()不会返回包含未签名的下载URL的UploadResponse。bucket.upload()包含UploadResponse,Get Download URL from file uploaded with Cloud Functions for Firebase有几个答案,解释了如何从UploadResponse获取未签名的下载URL。如何将代码中的file.createWriteStre
我正在尝试Node.js将多个文件从我的Google Compute Engine VM本地目录上传到我已经创建的GCS存储桶中。每次运行脚本时,我都会收到以下错误。
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type function
脚本:
`// Imports the Google Cloud client library
const {Storage} = require('@google-cloud/storage'
在Amazon中,在生成预签名的S3时,我可以生成一个设置content-disposition的URL,但我找不到使用谷歌配置这些选项的类似方法。
我们可以使用的方法调用是:
https://www.rubydoc.info/gems/google-cloud-storage/0.20.0/Google/Cloud/Storage/File#signed_url-instance_method
我正在尝试将文件直接上传到Google存储桶,而不是通过我的Rails服务器,并希望设置通过预签名URL上传的文件的内容处置。有没有办法做到这一点?有没有办法通过预签名的URL来设置对象元数据?
re
我正在将配置文件图像上传到google云存储(运行良好),并试图将所有图像公开,但是当在img内部使用或只是在浏览器中粘贴它时,我一直从返回的url中获取403错误,返回的url如下所示:
https://storage.googleapis.com/my_bucket_name/12370691_1205162746164520_2152367844899316112_o.jpg
它给出了以下错误:
Anonymous users does not have storage.objects.get access to object my_bucket_name/15991995_384418
我现在正在使用google存储公共桶为网络上的二进制资源提供服务。
正如文档所提到的,
The authenticated browser download endpoint storage.cloud.google.com does not allow CORS requests. Note that the Google Cloud console provides this endpoint for each object's public URL link.
因此,为了允许CORS,我需要将代理服务器放在前面。
我不知道有什么方法可以让我用CORS直接从云存储中获取资源,但不需
如何在中使用Django自定义存储后端?
尝试使用这个:
根据文档,我在“setings.py”中添加了以下内容:
GOOGLE_CLOUD_STORAGE_BUCKET = [my bucket name] # the name of the bucket you have created from the google cloud storage console
GOOGLE_CLOUD_STORAGE_URL = [my bucket URL] #whatever the url for accessing your cloud storgage bucket
GOOGLE_CLOUD_
我正在尝试编写一个函数来更新数据库中的节点,然后在默认存储桶中创建一个目录。
admin.database().ref('messages').push({ original: original })
.then(() => {
//looking for something like this
//functions.storage.object().mkdir('myFolder');
})
函数从防火墙文档使用const gcs = require('@google-cloud/storage
我正在GCP控制台中工作,并试图将file stores数据复制到google cloud storage --这是我使用的命令:
gsutil rsync -r /fileserver/demo/dir1 gs://corp-bucket/dir1
/fileserver/demo/dir1: mount point directory where the file store is mounted
corp-bucket: google cloud bucket
corp-bucket/dir1: folder I created in the bucket
这个命令将数据从文件存储区复
我在这里面临一个问题。我确实遵循了的两个答案,但仍然没有运气。当图像上传到桶中时,它没有设置为public
这是我的密码:
// Google API to create an absolute URL that can be used by a user to asynchronously upload a large blob
require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php';
use google\appengine\api\cloud_storage\CloudStorageT