本文整理汇总了Java中com.google.cloud.storage.Acl.Role类的典型用法代码示例。如果您正苦于以下问题:Java Role类的具体用法?Java Role怎么用?Java Role使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Role类属于com.google.cloud.storage.Acl包,在下文中一共展示了Role类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: uploadFile
import com.google.cloud.storage.Acl.Role; //导入依赖的package包/类
/**
* Uploads a file to Google Cloud Storage to the bucket specified in the BUCKET_NAME
* environment variable, appending a timestamp to end of the uploaded filename.
*/
@SuppressWarnings("deprecation")
public String uploadFile(Part filePart, final String bucketName) throws IOException {
DateTimeFormatter dtf = DateTimeFormat.forPattern("-YYYY-MM-dd-HHmmssSSS");
DateTime dt = DateTime.now(DateTimeZone.UTC);
String dtString = dt.toString(dtf);
final String fileName = filePart.getSubmittedFileName() + dtString;
// the inputstream is closed by default, so we don't need to close it here
BlobInfo blobInfo =
storage.create(
BlobInfo
.newBuilder(bucketName, fileName)
// Modify access list to allow all users with link to read file
.setAcl(new ArrayList<>(Arrays.asList(Acl.of(User.ofAllUsers(), Role.READER))))
.build(),
filePart.getInputStream());
logger.log(
Level.INFO, "Uploaded file {0} as {1}", new Object[]{
filePart.getSubmittedFileName(), fileName});
// return the public download link
return blobInfo.getMediaLink();
}
示例2: uploadFile
import com.google.cloud.storage.Acl.Role; //导入依赖的package包/类
/**
* Uploads a file to Google Cloud Storage to the bucket specified in the BUCKET_NAME
* environment variable, appending a timestamp to end of the uploaded filename.
*/
@SuppressWarnings("deprecation")
public String uploadFile(Part filePart, final String bucketName) throws IOException {
DateTimeFormatter dtf = DateTimeFormat.forPattern("-YYYY-MM-dd-HHmmssSSS");
DateTime dt = DateTime.now(DateTimeZone.UTC);
String dtString = dt.toString(dtf);
final String fileName = filePart.getSubmittedFileName() + dtString;
// the inputstream is closed by default, so we don't need to close it here
BlobInfo blobInfo =
storage.create(
BlobInfo
.newBuilder(bucketName, fileName)
// Modify access list to allow all users with link to read file
.setAcl(new ArrayList<>(Arrays.asList(Acl.of(User.ofAllUsers(), Role.READER))))
.build(),
filePart.getInputStream());
// return the public download link
return blobInfo.getMediaLink();
}
示例3: uploadFile
import com.google.cloud.storage.Acl.Role; //导入依赖的package包/类
/**
* Uploads a file to Google Cloud Storage to the bucket specified in the BUCKET_NAME
* environment variable, appending a timestamp to end of the uploaded filename.
*/
public String uploadFile(FileItemStream fileStream, final String bucketName)
throws IOException, ServletException {
checkFileExtension(fileStream.getName());
DateTimeFormatter dtf = DateTimeFormat.forPattern("-YYYY-MM-dd-HHmmssSSS");
DateTime dt = DateTime.now(DateTimeZone.UTC);
String dtString = dt.toString(dtf);
final String fileName = fileStream.getName() + dtString;
// the inputstream is closed by default, so we don't need to close it here
@SuppressWarnings("deprecation")
BlobInfo blobInfo =
storage.create(
BlobInfo
.newBuilder(bucketName, fileName)
// Modify access list to allow all users with link to read file
.setAcl(new ArrayList<>(Arrays.asList(Acl.of(User.ofAllUsers(), Role.READER))))
.build(),
fileStream.openStream());
logger.log(Level.INFO, "Uploaded file {0} as {1}", new Object[]{
fileStream.getName(), fileName});
// return the public download link
return blobInfo.getMediaLink();
}
示例4: uploadFile
import com.google.cloud.storage.Acl.Role; //导入依赖的package包/类
/**
* Uploads a file to Google Cloud Storage to the bucket specified in the BUCKET_NAME
* environment variable, appending a timestamp to end of the uploaded filename.
*/
@SuppressWarnings("deprecation")
public String uploadFile(FileItemStream fileStream, final String bucketName)
throws IOException, ServletException {
checkFileExtension(fileStream.getName());
DateTimeFormatter dtf = DateTimeFormat.forPattern("-YYYY-MM-dd-HHmmssSSS");
DateTime dt = DateTime.now(DateTimeZone.UTC);
String dtString = dt.toString(dtf);
final String fileName = fileStream.getName() + dtString;
// the inputstream is closed by default, so we don't need to close it here
BlobInfo blobInfo =
storage.create(
BlobInfo
.newBuilder(bucketName, fileName)
// Modify access list to allow all users with link to read file
.setAcl(new ArrayList<>(Arrays.asList(Acl.of(User.ofAllUsers(), Role.READER))))
.build(),
fileStream.openStream());
// return the public download link
return blobInfo.getMediaLink();
}
示例5: uploadFile
import com.google.cloud.storage.Acl.Role; //导入依赖的package包/类
/**
* Uploads a file to Google Cloud Storage to the bucket specified in the BUCKET_NAME
* environment variable, appending a timestamp to end of the uploaded filename.
*/
public String uploadFile(FileItemStream fileStream, final String bucketName)
throws IOException, ServletException {
checkFileExtension(fileStream.getName());
DateTimeFormatter dtf = DateTimeFormat.forPattern("-YYYY-MM-dd-HHmmssSSS");
DateTime dt = DateTime.now(DateTimeZone.UTC);
String dtString = dt.toString(dtf);
final String fileName = fileStream.getName() + dtString;
// the inputstream is closed by default, so we don't need to close it here
@SuppressWarnings("deprecation")
BlobInfo blobInfo =
storage.create(
BlobInfo
.newBuilder(bucketName, fileName)
// Modify access list to allow all users with link to read file
.setAcl(new ArrayList<>(Arrays.asList(Acl.of(User.ofAllUsers(), Role.READER))))
.build(),
fileStream.openStream());
// return the public download link
return blobInfo.getMediaLink();
}
示例6: exec
import com.google.cloud.storage.Acl.Role; //导入依赖的package包/类
@TaskAction
public void exec() {
ImmutableGcloudExtension config = getProject().getExtensions().getByType(GcloudExtension.class);
Storage cloudStorage =
StorageOptions.newBuilder().setProjectId(config.clusterProject()).build().getService();
cloudStorage
.create(BucketInfo.of(config.buildCacheStorageBucket()))
.createAcl(Acl.of(new Domain("istellar.jp"), Role.READER));
}