- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一个用 Python 编写的关于 GAE 的页面,它 (1) 将 jpg 上传到 blobstore。那部分有效。我现在需要进行 (2) 手气不错的图像转换,然后 (3) 将其作为另一个 blob 存储在 blobstore 中。理想情况下,我想在同一个上传处理程序中执行 (1)、(2) 和 (3)。
我已经按照此处的代码进行操作,但它只执行 (1) 和 (2)。 https://developers.google.com/appengine/docs/python/images/#Python_Transforming_images_from_the_Blobstore
我已经查看了 SO,我能找到的最接近的是: Storing Filtered images on the blobstore in GAE
它将转换保存到文件(使用 Files API),然后将文件上传到 blobstore。但是,它使用 Files api,并且根据以下内容,不推荐使用 Files API。 https://developers.google.com/appengine/docs/python/blobstore/#Python_Writing_files_to_the_Blobstore
在我的模型中,我有一个 BlobKeyProperty,它在 blobstore 中存储对图像的引用
class ImageModel(ndb.Model):
imagetoserve = ndb.BlobKeyProperty(indexed=False)
到目前为止,这是上传处理程序代码:
from google.appengine.ext import blobstore
from google.appengine.ext.webapp import blobstore_handlers
from google.appengine.api.images import get_serving_url
from google.appengine.api import images
upload_files = self.get_uploads('imgfile') # 'file' is file upload field in the form
blob_info = upload_files[0]
imgtmp = images.Image(blob_info)
imgtmp.im_feeling_lucky()
img = ImageModel()
img.imagetoserve = imgtmp
img.put()
我的问题是在这一行:
img.imagetoserve = imgtmp
该模型是一个 blobkey 属性,但我正在为其提供图像,显然会导致类型不匹配的错误。如何执行将转换后的 imgtmp 上传到 blobstore、捕获 blobkey 并将引用保存到我的模型的步骤?
最佳答案
不幸的是,传统上您会通过文件 API 完成此操作,但由于他们不赞成使用 GCS,您可以执行以下操作(您可以填写缺失的部分):(来自 this example)
import cloudstorage as gcs
from google.appengine.ext import blobstore
class ImageModel(ndb.Model):
image_filename = ndb.StringProperty(indexed=False)
@property
def imagetoserve(self):
return blobstore.create_gs_key(self.image_filename)
BUCKET = "bucket_to_store_image\\"
with gcs.open(BUCKET + blob_info.filename, 'w', content_type='image/png') as f:
f.write(imgtmp.execute_transforms())
img = ImageModel()
img.image_filename = BUCKET + blob_info.filename
img.put()
关于python - 在 UploadHandler 中执行图像转换并将其保存到 Blobstore,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18140142/
我正在 appengine 中开发一个应用程序,我们希望能够向离线用户提供内容。这意味着我们需要获取所有使用过的 blobstore 文件并为离线用户保存它们。我使用服务器端来执行此操作,以便只执行一
" method="post" enctype="multipart/form-data" >
我确实需要上传大于 1 Mb 的文件,所以我只有 Blobstore API。但在生产中使用它吗?知道任何问题吗? 最佳答案 我很高兴地使用了 Google 内部的等效功能(我在 Google 工作)
我想从另一个站点获取图像 (~250Kb) 并将它们保存到 blobstore 。我想使用 Blobstore,因为它的配额(5Gb 免费)与数据存储(1Gb 免费)相比。我该怎么做? GAE 文档说
我正在尝试将表单中的多个文件上传到 BlobStore。 表格: Key Name name image thumb 然后我尝试为每个上传的文件获取 BlobInfo 对象:
在我的应用程序中,我需要执行以下操作:1. 将包含图像(目前只有 jpg)和其他内容的 zip 文件上传到 BlobStore。2. 应用引擎后端应从上传的 zip 中读取条目,并将在其中找到的所有图
我正在尝试对一些使用 Blobstore API 的代码进行单元测试,但是我收到此代码的 NullPointerException : @ContextConfiguration(locations
在接下来的几天里,我必须开始编写一些报告生成函数。我需要写入调用是原子的,并让我知道存储时是否出现故障。 appengine 上的一项实验性功能允许使用 blobstore 作为文件系统。(https
上传文件名包含空格且不带文件扩展名的文本文件会引发以下异常。文件名类似于“README TXT”或“ABC DEF”。 使用 Blobstore 示例可以重现此问题。 https://develope
我有这个上传文件的jsp 文件。我添加了姓名和电子邮件表格。我希望能够跟踪上传到我的应用程序引擎 blobstore 的哪个 blob 来自哪个人。我是否必须绑定(bind)数据存储才能获取联系信息?
我尝试使用下面的代码使用curl将图像上传到blobstore,但收到以下错误“必须从blob上传回调请求调用”。 但是,如果我使用带有操作的表单,它会上传: blobstoreService.cre
我正在将数据上传到 blobstore。它应该只暂时停留在那里,并从我的 AppEngine 应用程序中上传到 Amazon S3。 看来我只能通过 BlobDonwloadHandler 获取数据,
我目前正在 Appengine 中制作一个图像共享网站,它主要按照我想要的方式工作,但有时我想要一个小版本的图像(缩略图) - 目前我正在使用 HTML 缩小它,但是当完全没有必要时,浏览器仍然会加载
我可以使用 python 中的 uploadhandler 上传文件。当我尝试获取文件的 url 时,我收到错误“Assertionerror images the service does not
关注此blobstore document 关于如何上传到 Blobstore。它显示了通过JSP + Servlet 方式上传。 由于我的应用程序基于 GWT,因此我需要调整 GWT RPC(而不是
假设我有一些文件上传表单,例如文档中的文件 https://cloud.google.com/appengine/docs/java/blobstore/ 如果我将文件 file.txt 保存到 bl
我想使用 BlobstoreInputStream 从 Blobstore 一次读取一行文本并处理该文本 123,ABC,DEF,GHI,JKL,123,456,789,123\r\n 但是 Blob
我阅读了文档,四处搜索,但仍然不知道如何将 blob 读取为字节数组。 我能够生成 PDF 文件并将它们存储在 blobstore 中。我还可以使用 serve() 为这些 blob 提供下载服务,没
我正在阅读有关 Google App Engine 中的 Blobstore 的信息。下面的代码来自示例文档。用户选择要上传的文件并单击提交后,如何将 key 放入 javascript 变量中?我可
我正在尝试使用 taskqueue 和 deferred 将大型用户信息列表从 json 文件导入到数据存储区。 User 包含用户信息,包括来自不同应用的图像 url。在导入过程中,应该抓取图像并将
我是一名优秀的程序员,十分优秀!