getServingUrl() 使用 Google Cloud Storage 值的方法 [英] getServingUrl() Method using Google Cloud Storage value
本文介绍了getServingUrl() 使用 Google Cloud Storage 值的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在不使用 Blob 的情况下使用 getServingUrl() 为图像创建基本 URL?到目前为止,我看到的所有示例都涉及 blob,但我需要使用 Google Cloud Storage 值.
how would you create a basic URL for an image using getServingUrl() without using Blobs? All the examples I've seen so far involved blobs, but I need to use Google Cloud Storage value.
谢谢.
推荐答案
getServingUrl()
有一个新的重载,带有一个 ServingUrlOptions
方法参数.它的构建器有一个 withGoogleStorageFileName()
方法,您可以使用该方法根据 Cloud Storage 文件名创建网址.
There is a new overload for getServingUrl()
with a ServingUrlOptions
method argument. And its builder has a withGoogleStorageFileName()
method that you can use to create a URL based on the Cloud Storage filename.
GcsFilename gcsFilename = new GcsFilename("bucketName", "objectName");
ImagesService is = ImagesServiceFactory.getImagesService();
String filename = String.format("/gs/%s/%s", gcsFilename.getBucketName(), gcsFilename.getObjectName());
String servingUrl = is.getServingUrl(ServingUrlOptions.Builder.withGoogleStorageFileName(filename));
Java 文档:
- https://developers.google.com/appengine/docs/java/javadoc/com/google/appengine/api/images/ImagesService.html#getServingUrl(com.google.appengine.api.images.ServingUrlOptions)
- https://developers.google.com/appengine/docs/java/javadoc/com/google/appengine/api/images/ServingUrlOptions.Builder.html
这篇关于getServingUrl() 使用 Google Cloud Storage 值的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文