将 Images/Videos 从 Android/iOS 发送到 Google Cloud Endpoints
Send Images/Videos from Android/iOS to Google Cloud Endpoints
我真的需要你的help/suggestion/clue/etc。我正在为 Android 和 iOS 开发一个应用程序,它允许用户上传图片和视频。
我想做什么:
1 - Android/iOS 发送 picture/video 到我的 Google 云端点;
2 - Google Cloud Endpoint 将 image/video 上传到 Google Cloud Storage; (作品)
3 - Google Cloud Endpoint 从 Google Cloud Storage 检索服务 URL 并发送回 Android/iOS; (作品)
4 - Android/iOS 通过其 URL 流式传输 picture/video。 (作品)
所以问题只是第一步,将 image/video 发送到 Google Cloud Endpoint。
我读了很多书,搜索过,研究过,但不知道该怎么做。
拜托,任何建议将不胜感激。我也乐于接受有关实现此功能的方式的新想法。谢谢大家!
.
- - - - - - - - - - - - - - - - - - - - - - - - - 更新 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.
经过更多研究后,我注意到更好的方法是直接从 Android/iOS 上传。我想出了如何去做,但现在我陷入了如何实现 servlet 以在客户端使用我的端点生成的 urlUpload 上传文件后自动调用的问题。
到目前为止我做了:
1 - 客户端请求我的 Google 端点以检索 URL 以进行上传;
2 - Google 端点生成 '/upload' url 使用此代码:
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 并上传文件(我还没有实现它,但我看到了很多干净的例子并且看起来很容易理解)
4 - Blobstore 服务触发 Google 端点作为上传对象的回调发送键
5 - 我使用 Blob 密钥检索服务URL 以向客户端提供文件 (Android/iOS)(已实现)
一旦我看到的所有教程和示例都没有使用 Google Cloud Endpoints,我不知道如何实施第 4 步。拜托,有没有人能给我 path/link/code 或如何实施它的线索?
如果您使用的是 Endpoints 框架,则很难做到这一点。对于单个图像,您可以对其进行 base64 编码,但效率不高。对于您的客户来说,直接与 GCS 交互并使用签名的 URL 进行上传可能效果更好。
正如 Saiyr 所建议的,您应该直接从 Android 应用程序上传到云存储(不通过端点)。参见 Uploading image from Android to GCS and 。
既然知道bucket和文件名,那么上传文件的URL很容易扣,看下面的文档决定使用哪个URL(取决于用户是否需要是否经过身份验证,请参阅第 "A user is granted read access to an object") https://cloud.google.com/storage/docs/cloud-console#_accessing
节
我真的需要你的help/suggestion/clue/etc。我正在为 Android 和 iOS 开发一个应用程序,它允许用户上传图片和视频。
我想做什么:
1 - Android/iOS 发送 picture/video 到我的 Google 云端点;
2 - Google Cloud Endpoint 将 image/video 上传到 Google Cloud Storage; (作品)
3 - Google Cloud Endpoint 从 Google Cloud Storage 检索服务 URL 并发送回 Android/iOS; (作品)
4 - Android/iOS 通过其 URL 流式传输 picture/video。 (作品)
所以问题只是第一步,将 image/video 发送到 Google Cloud Endpoint。
我读了很多书,搜索过,研究过,但不知道该怎么做。
拜托,任何建议将不胜感激。我也乐于接受有关实现此功能的方式的新想法。谢谢大家!
.
- - - - - - - - - - - - - - - - - - - - - - - - - 更新 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
.
经过更多研究后,我注意到更好的方法是直接从 Android/iOS 上传。我想出了如何去做,但现在我陷入了如何实现 servlet 以在客户端使用我的端点生成的 urlUpload 上传文件后自动调用的问题。
到目前为止我做了:
1 - 客户端请求我的 Google 端点以检索 URL 以进行上传;
2 - Google 端点生成 '/upload' url 使用此代码:
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 并上传文件(我还没有实现它,但我看到了很多干净的例子并且看起来很容易理解)
4 - Blobstore 服务触发 Google 端点作为上传对象的回调发送键
5 - 我使用 Blob 密钥检索服务URL 以向客户端提供文件 (Android/iOS)(已实现)
一旦我看到的所有教程和示例都没有使用 Google Cloud Endpoints,我不知道如何实施第 4 步。拜托,有没有人能给我 path/link/code 或如何实施它的线索?
如果您使用的是 Endpoints 框架,则很难做到这一点。对于单个图像,您可以对其进行 base64 编码,但效率不高。对于您的客户来说,直接与 GCS 交互并使用签名的 URL 进行上传可能效果更好。
正如 Saiyr 所建议的,您应该直接从 Android 应用程序上传到云存储(不通过端点)。参见 Uploading image from Android to GCS and
既然知道bucket和文件名,那么上传文件的URL很容易扣,看下面的文档决定使用哪个URL(取决于用户是否需要是否经过身份验证,请参阅第 "A user is granted read access to an object") https://cloud.google.com/storage/docs/cloud-console#_accessing
节