我想将文件上传到 Google Cloud Storage,但是出现如下错误:
java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkNotNull
我要上传到 Google Cloud Storage 的 xml 文件的格式:
<set xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
文件和谷歌存储桶,我想将文件上传到存储桶。
字符串文件名 = “data.xml”
String fileBucket = "上传文件";
public static void uploadFile(String fileName, String fileBucket)
throws IOException {
final GcsService gcsService = GcsServiceFactory.createGcsService(new RetryParams.Builder()
.initialRetryDelayMillis(10)
.retryMaxAttempts(10)
.totalRetryPeriodMillis(50000)//15000
.build());
gcsService.createOrReplace(
new GcsFilename(fileBucket, fileName),
new GcsFileOptions.Builder().mimeType("application/xml")
.acl("public-read")
.cacheControl("public, max-age=0").build());
}
跃然一笑
相关分类