當前位置: 首頁>>代碼示例>>Java>>正文


Java S3ObjectSummary.getSize方法代碼示例

本文整理匯總了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);
}
 
開發者ID:lithiumtech,項目名稱:flow,代碼行數:17,代碼來源:S3Filer.java

示例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!");
    }
}
 
開發者ID:Axway,項目名稱:ats-framework,代碼行數:17,代碼來源:S3Operations.java

示例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);
}
 
開發者ID:SparkTC,項目名稱:stocator,代碼行數:16,代碼來源:COSUtils.java

示例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()
                 );
 }
 
開發者ID:snowflakedb,項目名稱:snowflake-jdbc,代碼行數:19,代碼來源:StorageObjectSummary.java

示例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;
}
 
開發者ID:modcs,項目名稱:caboclo,代碼行數:28,代碼來源:AmazonClient.java

示例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;
}
 
開發者ID:jtran064,項目名稱:PlatePicks-Android,代碼行數:7,代碼來源:S3ContentSummary.java

示例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);
}
 
開發者ID:OptimalBI,項目名稱:optimal-spyglass-open-source,代碼行數:67,代碼來源:ServiceDraw.java

示例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;
}
 
開發者ID:FINRAOS,項目名稱:herd,代碼行數:53,代碼來源:S3DaoImpl.java


注:本文中的com.amazonaws.services.s3.model.S3ObjectSummary.getSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。