使用Google Endpoints在Google云端存储上上传图片

时间:2023-01-06 23:10:17

I'm trying to create a RESTFul Web Service for upload photos. Is it possible create a Google Cloud Endpoints to upload images/photos? My problem is that I can't understand how to write the function declaration and which parameters I need to handle.

我正在尝试为上传照片创建RESTFul Web服务。是否可以创建Google Cloud Endpoints来上传图片/照片?我的问题是我无法理解如何编写函数声明以及我需要处理哪些参数。

public void uploadPhoto(@Named("token") String token, @Named("title") String title, @Named("description") String description, @Named("photo") HttpServletRequest req) {}

If I handle value of req, what I will find in it? Thank you

如果我处理req的价值,我会在其中找到什么?谢谢

1 个解决方案

#1


0  

The easiest way to do this is store your image as a base64 encoded string. Then you treat it exactly the same way you would any other string in your request.

最简单的方法是将图像存储为base64编码的字符串。然后,您对待它的方式与请求中的任何其他字符串完全相同。

Once you get it to appengine you can decode the base64 and upload it using the blobstore api as normal.

一旦你得到appengine你可以解码base64并正常使用blobstore api上传它。

Note: as some commentators have said uploading directly to GCS may be a more elegant solution.

注意:正如一些评论员所说,直接上传到GCS可能是一个更优雅的解决方案。

#1


0  

The easiest way to do this is store your image as a base64 encoded string. Then you treat it exactly the same way you would any other string in your request.

最简单的方法是将图像存储为base64编码的字符串。然后,您对待它的方式与请求中的任何其他字符串完全相同。

Once you get it to appengine you can decode the base64 and upload it using the blobstore api as normal.

一旦你得到appengine你可以解码base64并正常使用blobstore api上传它。

Note: as some commentators have said uploading directly to GCS may be a more elegant solution.

注意:正如一些评论员所说,直接上传到GCS可能是一个更优雅的解决方案。