简体   繁体   English

如何在开发服务器(Google App Engine)中使用生产BlobStore

[英]How to use production BlobStore in development server (Google App Engine)

I'm developing an application on Python Google App Engine and I'm using the BlobStore to store image data. 我正在使用Python Google App Engine开发一个应用程序,我正在使用BlobStore来存储图像数据。

I've backed up all my database information to my local host to set up a local development environment but I want to use the Blobs Images from my Production server (so I don't have to copy all files to my local computer). 我已将所有数据库信息备份到本地主机以设置本地开发环境但我想使用生产服务器中的Blobs映像(因此我不必将所有文件复制到本地计算机)。

When I call images.get_serving_url() to get the image url it returns a local reference to it that doesn't exist (since all the images are in the prod server). 当我调用images.get_serving_url()来获取图像url时,它返回一个不存在的本地引用(因为所有图像都在prod服务器中)。

Is there a way to configure the images class to point to my prod server? 有没有办法配置图像类指向我的prod服务器? If the answer is no, how can I redirect the calls from my dev server that hit /_ah/img/ to my prod server? 如果答案是否定的,我如何将来自我的开发服务器的调用重命名为/ _ah / img /到我的prod服务器?

from google.appengine.api import images
print images.get_serving_url(page, size=100)

>> http://0.0.0.0:8080/_ah/img/AMIfv96IySWiIWF-4FRipavsn9xXnkk-EhmNOU0qWZ4y0ORIXj0Ct85C9eXMBdv3JVooWPIm6-2D3U9ffuTtpJEkWh13ZzmmaNKSiu5QMsnk0exNWj7g1OWbpNxcsjtmv52wz94QFQ6xCNz-atycTqfkdDHbX-LWmMqlsrVEs86S4wsAKSNOZZE=s100

I wish the output from this call was my prod server url. 我希望这次调用的输出是我的prod服务器url。

What you're asking isn't possible. 你问的是不可能的。

The image blob keys are more or less randomly generated. 图像blob键或多或少地随机生成。 ie, when you upload a blob to the production Blobstore, it gets a key generated. 即,当您将Blob上载到生产Blobstore时,它会生成一个密钥。

There's no way for the dev appserver to know the key for a given image on the production server. dev appserver无法知道生产服务器上给定映像的密钥。 If you "upload" the same image to the dev_appserver, it'll get a completely different key. 如果您将相同的图像“上传”到dev_appserver,它将获得完全不同的密钥。

Your options are either to download all the images locally and "upload" them to your local dev server. 您可以选择在本地下载所有图像并将其“上传”到本地开发服务器。 If you're using Google Cloud Storage, the gsutil tool might help: https://developers.google.com/storage/docs/gsutil 如果您使用的是Google云端存储,gsutil工具可能会有所帮助: https//developers.google.com/storage/docs/gsutil

Or find all the blobstore urls on the server and manually map them in your own application. 或者在服务器上找到所有blobstore URL并在您自己的应用程序中手动映射它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM