次のコードを使用して、GoogleAppEngineアプリケーションに画像を正常に投稿しています。
def post(self):
image_data = self.request.get('file')
file_name = files.blobstore.create(mime_type='image/png')
# Open the file and write to it
with files.open(file_name, 'a', exclusive_lock=True) as f:
f.write(image_data)
# Finalize the file. Do this before attempting to read it.
files.finalize(file_name)
# Get the file's blob key
blob_key = files.blobstore.get_blob_key(file_name)
self.response.out.write(images.get_serving_url( blob_key ))
ただし、によって出力されたURLを参照するget_serving_url()
と、画像は常に低解像度になります。なんで?投稿されている画像が正しいサイズであることを確認し、再確認しました(iPhoneカメラからの場合、解像度は約3200x2400です)。ただし、提供される画像は常に512x384です。
私はGAEにかなり慣れていませんが、上記のコードは1 MBの制限を回避して、データストアではなくBlobStoreに画像を保存する必要があると思いました。
誰かが何が起こっているのか考えていますか?
乾杯、ブレット