gpt4 book ai didi

python - Google App Engine - 将 Blobstore API 与 Google Cloud Storage 结合使用

转载 作者:太空宇宙 更新时间:2023-11-04 09:01:51 24 4
gpt4 key购买 nike

我不得不存储大小超过 1MB 的文件,谷歌应用引擎建议我应该将它们存储在谷歌云存储中。应用引擎 BlobProperty 不合适。

本节Using Blobstore API with Google Cloud Storage建议使用 create_upload_url 函数的 gs_bucket_name 参数。

我试过了。

gcs_upload_url = blobstore.create_upload_url('/myupload', gs_bucket_name='bucketname.appspot.com/')

我为 POST 获得的结果 URL 不是 /myupload,有点像

<form action="http://myapp.appspot.com/_ah/upload/XXXXXXXXXXX7NNN-XXXXYYY/" method="post" enctype="multipart/form-data">

我已经更改了/upload/之后的部分,但重点是,它显然没有创建正确的上传 URL,我的处理程序可以识别它。

将 create_upload_url 与 gs_bucket_name 一起使用并获取正确的 URL 以处理帖子的正确方法是什么?

显然官方文档在这里没有帮助。

最佳答案

你在create_upload_url函数中传入的路径是success_path。请参阅下面的说明。

The URL path of the request handler that will process the upload request, after the file submitted with the form has been uploaded to the Blobstore.

文件上传到 BlobStore 或 Google Cloud Storage 后,App Engine 会调用 success_path。

When the user submits an upload web form, the uploaded data goes directly to the Blobstore or to Google Cloud Storage if you use that instead of Blobstore. (Google Cloud Storage requires the gs_bucket_name parameter.) The Blobstore rewrites the incoming request to remove the uploaded data (the MIME part body) and add the Blobstore key (as a header in the MIME part), then passes the rewritten request to the application handler associated with the URL path given to create_upload_url() as success_path. The handler at that path can process the rest of the form.

此函数提供的 URL 旨在用作上传表单的操作。您提供的路径类似于上传后处理程序。

关于python - Google App Engine - 将 Blobstore API 与 Google Cloud Storage 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24592661/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com