将图像/视频从Android/iOS发送到Google Cloud Endpoints [英] Send Images/Videos from Android/iOS to Google Cloud Endpoints

查看:273
本文介绍了将图像/视频从Android/iOS发送到Google Cloud Endpoints的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的需要您的帮助/建议/线索/等.我正在开发适用于Android和iOS的应用程序,该应用程序将允许用户上传图片和视频.

I'm really needing your help/suggestion/clue/etc. I'm developing an application for Android and iOS which will allow the user to upload pictures and videos.

我要做什么:

1-Android/iOS将图片/视频发送到我的Google Cloud Endpoint;

2-Google Cloud Endpoint将图像/视频上传到Google Cloud Storage; (工作)

2 - Google Cloud Endpoint upload the image/video to Google Cloud Storage; (Works)

3-Google Cloud Endpoint从Google Cloud Storage检索服务URL并发送回Android/iOS; (工作)

3 - Google Cloud Endpoint retrieve the servingURL from Google Cloud Storage and send back to Android/iOS; (Works)

4-Android/iOS通过其URL传输图片/视频. (工作)

4 - Android/iOS stream the picture/video by its URL. (Works)

所以问题只是第一步,将图像/视频发送到Google Cloud Endpoint.

So the problem is just the first step, send the image/video to Google Cloud Endpoint.

我正在阅读,搜索,研究很多东西,却不知道该怎么做.

I'm reading a lot, searching, researching and didn't figured out how to do it.

请,任何建议将不胜感激.我也对实现此功能的方式持开放态度.谢谢你们!

Please, ANY suggestion will be appreciate. I'm open to new ideas about the way to implement this feature as well. Thank you guys!

.

--------------------------UPDATE--------------- -------------------

.

经过更多研究后,我注意到更好的方法是直接从Android/iOS上传.我想出了办法,但是现在我陷入了如何实现servlet的问题,即客户端使用由我的端点生成的urlUpload上传文件后自动调用该servlet.

After research a bit more I noticed the better way to do it would be uploading straight from Android/iOS. I figured out how to do it but now I got stuck about how to implement the servlet to get called automatically after the client upload the file using the urlUpload generated by my endpoint.

到目前为止,我做到了:

So far I did:

1-客户端请求我的Google端点检索要上传的URL;

1 - Client request my Google Endpoint to retrieve URL for upload;

2-Google端点使用以下代码生成"/upload"网址:

2 - Google Endpoint generates '/upload' url using with this code:

BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
UploadOptions uploadOptions = UploadOptions.Builder.withGoogleStorageBucketName(ConstUtil.storage.BUCKET_NAME);

String uploadUrl = blobstoreService.createUploadUrl("/upload", uploadOptions);

response.setSimpleString(uploadUrl);
response.setCode(MWCode.SUCCESS.getCode());
response.setMessage(MWCode.SUCCESS.getMessage());

return response;

3-客户端(Android/iOS)接收此URL并上传文件(我尚未实现它,但我看到了很多干净的示例,看起来非常易于理解)

3 - Client (Android/iOS) receive this url and upload the file (I didn't implement it yet but I saw many clean example and looks very easy to understand)

4-Blobstore服务将Google Endpoint触发为上载对象的回调发送键

5-我使用Blob键来检索serveURL,以便通过客户端(Android/iOS)(已实现)为文件提供文件

5 - I use Blob keys to retrieve servingURL to serve the files with clients (Android/iOS) (already implemented)

一旦我看到的所有教程和示例均未使用Google Cloud Endpoints,我就不知道如何实施第4步.拜托,有没有人可以给我路径/链接/代码或如何实现它的线索?

I have no idea about how to implement the step 4 once all tutorials and examples I see are not using Google Cloud Endpoints. Please, does anyone can give me the path/link/code or clue of how I could implement it?

推荐答案

正如Saiyr所建议的那样,您应该直接从Android应用程序上传到Cloud Storage(不要通过Endpoints).请参见从Android将图像上传到GCS

As Saiyr suggested, you should upload directly to the Cloud Storage from the Android application (without going through Endpoints). See Uploading image from Android to GCS and upload image to google cloud storage with an application android.

由于您知道存储段和文件名,因此可以轻松扣除上载文件的URL,请参阅以下文档来确定要使用的URL(取决于是否对用户进行身份验证,请参阅用户被授权授予对对象的读取权限") https://cloud.google.com/storage/docs/cloud-console#_accessing

Since you know the bucket and file name, the URL of the uploaded file is easily deductible, see the following documentation to decide which URL to use (depending on whether the user shall be authenticated or not, see Section "A user is granted read access to an object") https://cloud.google.com/storage/docs/cloud-console#_accessing

这篇关于将图像/视频从Android/iOS发送到Google Cloud Endpoints的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆