本文整理汇总了Java中com.amazonaws.services.s3.model.S3ObjectSummary.getSize方法的典型用法代码示例。如果您正苦于以下问题:Java S3ObjectSummary.getSize方法的具体用法?Java S3ObjectSummary.getSize怎么用?Java S3ObjectSummary.getSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.amazonaws.services.s3.model.S3ObjectSummary
的用法示例。
在下文中一共展示了S3ObjectSummary.getSize方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRecord
import com.amazonaws.services.s3.model.S3ObjectSummary; //导入方法依赖的package包/类
@Override
@Nonnull
public Record getRecord(@Nonnull String path) throws IOException {
ObjectListing listing = s3.listObjects(
new ListObjectsRequest().withBucketName(bucket).withPrefix(path.substring(1)));
S3ObjectSummary summary = listing.getObjectSummaries().stream().findFirst().orElse(null);
if (summary == null) {
return Record.noFile(uri, path);
}
long time = summary.getLastModified().getTime();
long size = summary.getSize();
boolean directory = summary.getKey().endsWith("/");
return new Record(uri, RecordPath.from("/" + summary.getKey()), time, size, directory);
}
示例2: getFileSize
import com.amazonaws.services.s3.model.S3ObjectSummary; //导入方法依赖的package包/类
/**
* Get size of the specified object/file
*
* @param objectName the object name
* @return the size of the object in bytes
*/
@PublicAtsApi
public long getFileSize( String objectName ) {
S3ObjectSummary element = getBucketElement("", ".*", true, objectName);
if (element != null) {
return element.getSize();
} else {
throw new NoSuchElementException("Object with name '" + objectName + "' does not exist!");
}
}
示例3: createFileStatus
import com.amazonaws.services.s3.model.S3ObjectSummary; //导入方法依赖的package包/类
/**
* Create a files status instance from a listing.
* @param keyPath path to entry
* @param summary summary from AWS
* @param blockSize block size to declare
* @return a status entry
*/
public static COSFileStatus createFileStatus(Path keyPath,
S3ObjectSummary summary,
long blockSize) {
long size = summary.getSize();
return createFileStatus(keyPath,
objectRepresentsDirectory(summary.getKey(), size),
size, summary.getLastModified(), blockSize);
}
示例4: createFromS3ObjectSummary
import com.amazonaws.services.s3.model.S3ObjectSummary; //导入方法依赖的package包/类
/**
* Contructs a StorageObjectSummary object from the S3 equivalent S3ObjectSummary
* @param objSummary the AWS S3 ObjectSummary object to copy from
* @return the ObjectSummary object created
*/
public static StorageObjectSummary createFromS3ObjectSummary(S3ObjectSummary objSummary)
{
return new StorageObjectSummary(
objSummary.getBucketName(),
objSummary.getKey(),
// S3 ETag is not always MD5, but since this code path is only
// used in skip duplicate files in PUT command, It's not
// critical to guarantee that it's MD5
objSummary.getETag(),
objSummary.getSize()
);
}
示例5: getChildren
import com.amazonaws.services.s3.model.S3ObjectSummary; //导入方法依赖的package包/类
@Override
public List<RemoteFile> getChildren(String folderName) throws IOException {
if (!folderName.endsWith("/")) {
folderName = folderName + "/";
}
ListObjectsRequest listRequest = new ListObjectsRequest();
listRequest.setBucketName(getBucketName());
listRequest.setDelimiter("/");
listRequest.setPrefix(folderName);
ObjectListing listing = s3.listObjects(listRequest);
ArrayList<RemoteFile> list = new ArrayList<>();
for (S3ObjectSummary summ : listing.getObjectSummaries()) {
String name = summ.getKey();
long size = summ.getSize();
boolean isDirectory = isFolder(name);
RemoteFile file = new RemoteFile(name, isDirectory, size);
list.add(file);
}
return list;
}
示例6: S3ContentSummary
import com.amazonaws.services.s3.model.S3ObjectSummary; //导入方法依赖的package包/类
public S3ContentSummary(final S3ObjectSummary objectSummary, final String filePath) {
lastModifiedTime = objectSummary.getLastModified().getTime();
size = objectSummary.getSize();
path = filePath;
this.contentState = ContentState.REMOTE;
}
示例7: s3Calculate
import com.amazonaws.services.s3.model.S3ObjectSummary; //导入方法依赖的package包/类
private void s3Calculate(Service s3Service, Label objectCount, Label size) {
Platform.runLater(() -> {
size.setCursor(Cursor.DEFAULT);
size.setOnMouseClicked(null);
size.setTextFill(Color.PURPLE);
size.setText("Calculating");
objectCount.setCursor(Cursor.DEFAULT);
objectCount.setOnMouseClicked(null);
objectCount.setText("Calculating");
objectCount.setTextFill(Color.PURPLE);
});
Validate.notNull(s3Service);
Validate.notNull(objectCount);
Validate.notNull(size);
if (!(s3Service instanceof LocalS3Service)) {
System.err.println("Not instance of s3 for s3Calculate");
return;
}
LocalS3Service s3 = (LocalS3Service) s3Service;
List<S3ObjectSummary> objectSummaries = s3.getObjectSummaries();
String sizeString = " B";
double sizeCount = 0;
int objects = 0;
for (S3ObjectSummary summary : objectSummaries) {
sizeCount += summary.getSize();
objects++;
}
if (sizeCount > 1024) {
sizeCount = sizeCount / 1024;
sizeString = " KB";
}
if (sizeCount > 1024) {
sizeCount = sizeCount / 1024;
sizeString = " MB";
}
if (sizeCount > 1024) {
sizeCount = sizeCount / 1024;
sizeString = " GB";
}
sizeCount = Main.round(sizeCount, 1);
String objectsString = String.valueOf(objects);
String sizeStr = sizeCount + sizeString;
Platform.runLater(() -> {
objectCount.setText(objectsString);
objectCount.getStyleClass().removeAll("hyperlink");
objectCount.setTextFill(Color.BLACK);
objectCount.setCursor(Cursor.DEFAULT);
objectCount.setOnMouseClicked(null);
size.setText(sizeStr);
size.getStyleClass().removeAll("hyperlink");
size.setTextFill(Color.BLACK);
size.setCursor(Cursor.DEFAULT);
size.setOnMouseClicked(null);
});
s3.setSize(sizeStr);
s3.setNumberOfObjects(objects);
}
示例8: listDirectory
import com.amazonaws.services.s3.model.S3ObjectSummary; //导入方法依赖的package包/类
@Override
public List<S3ObjectSummary> listDirectory(final S3FileTransferRequestParamsDto params, boolean ignoreZeroByteDirectoryMarkers)
{
Assert.isTrue(!isRootKeyPrefix(params.getS3KeyPrefix()), "Listing of S3 objects from root directory is not allowed.");
AmazonS3Client s3Client = getAmazonS3(params);
List<S3ObjectSummary> s3ObjectSummaries = new ArrayList<>();
try
{
ListObjectsRequest listObjectsRequest = new ListObjectsRequest().withBucketName(params.getS3BucketName()).withPrefix(params.getS3KeyPrefix());
ObjectListing objectListing;
do
{
objectListing = s3Operations.listObjects(listObjectsRequest, s3Client);
for (S3ObjectSummary objectSummary : objectListing.getObjectSummaries())
{
// Ignore 0 byte objects that represent S3 directories.
if (!(ignoreZeroByteDirectoryMarkers && objectSummary.getKey().endsWith("/") && objectSummary.getSize() == 0L))
{
s3ObjectSummaries.add(objectSummary);
}
}
listObjectsRequest.setMarker(objectListing.getNextMarker());
}
while (objectListing.isTruncated());
}
catch (AmazonS3Exception amazonS3Exception)
{
if (S3Operations.ERROR_CODE_NO_SUCH_BUCKET.equals(amazonS3Exception.getErrorCode()))
{
throw new IllegalArgumentException("The specified bucket '" + params.getS3BucketName() + "' does not exist.", amazonS3Exception);
}
throw new IllegalStateException("Error accessing S3", amazonS3Exception);
}
catch (AmazonClientException e)
{
throw new IllegalStateException(String
.format("Failed to list keys with prefix \"%s\" from bucket \"%s\". Reason: %s", params.getS3KeyPrefix(), params.getS3BucketName(),
e.getMessage()), e);
}
finally
{
// Shutdown the AmazonS3Client instance to release resources.
s3Client.shutdown();
}
return s3ObjectSummaries;
}