本文整理汇总了Java中org.jets3t.service.model.StorageObject.getKey方法的典型用法代码示例。如果您正苦于以下问题:Java StorageObject.getKey方法的具体用法?Java StorageObject.getKey怎么用?Java StorageObject.getKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jets3t.service.model.StorageObject
的用法示例。
在下文中一共展示了StorageObject.getKey方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: list
import org.jets3t.service.model.StorageObject; //导入方法依赖的package包/类
/**
* list objects
* @param prefix prefix
* @param delimiter delimiter
* @param maxListingLength max no. of entries
* @param priorLastKey last key in any previous search
* @return a list of matches
* @throws IOException on any reported failure
*/
private PartialListing list(String prefix, String delimiter,
int maxListingLength, String priorLastKey) throws IOException {
try {
if (!prefix.isEmpty() && !prefix.endsWith(PATH_DELIMITER)) {
prefix += PATH_DELIMITER;
}
StorageObjectsChunk chunk = s3Service.listObjectsChunked(bucket.getName(),
prefix, delimiter, maxListingLength, priorLastKey);
FileMetadata[] fileMetadata =
new FileMetadata[chunk.getObjects().length];
for (int i = 0; i < fileMetadata.length; i++) {
StorageObject object = chunk.getObjects()[i];
fileMetadata[i] = new FileMetadata(object.getKey(),
object.getContentLength(), object.getLastModifiedDate().getTime());
}
return new PartialListing(chunk.getPriorLastKey(), fileMetadata,
chunk.getCommonPrefixes());
} catch (ServiceException e) {
handleException(e, prefix);
return null; // never returned - keep compiler happy
}
}
示例2: verifyExpectedAndActualETagValues
import org.jets3t.service.model.StorageObject; //导入方法依赖的package包/类
/**
* Compares the expected and actual ETag value for an uploaded object, and throws an
* ServiceException if these values do not match.
*
* @param expectedETag
* @param uploadedObject
* @throws org.jets3t.service.ServiceException
*/
protected void verifyExpectedAndActualETagValues(String expectedETag, StorageObject uploadedObject)
throws ServiceException
{
// Special handling for S3 MultiPart Part uploads, for which the response's ETag value is
// an opaque value and is not a hex-encoded MD5 hash value of the uploaded data like all
// other S3 ETag response values (Issue #141).
// See https://forums.aws.amazon.com/thread.jspa?messageID=203436𱪬
if (expectedETag.length() != 32) {
log.warn("The ETag header value '" + expectedETag + "' returned for "
+ uploadedObject + " is not a valid hex-encoded MD5 hash value;"
+ " cannot verify the correctness of the uploaded data");
return;
}
// Compare our locally-calculated hash with the ETag returned by S3.
if (!expectedETag.equals(uploadedObject.getETag())) {
throw new ServiceException("Mismatch between MD5 hash of uploaded data ("
+ expectedETag + ") and ETag returned by S3 ("
+ uploadedObject.getETag() + ") for object key: "
+ uploadedObject.getKey());
} else {
if (log.isDebugEnabled()) {
log.debug("Object upload was automatically verified, the calculated MD5 hash "+
"value matched the ETag returned by S3: " + uploadedObject.getKey());
}
}
}
示例3: assertValidObject
import org.jets3t.service.model.StorageObject; //导入方法依赖的package包/类
/**
* Throws an exception if an object is null or contains a null/empty key.
* @param object
* @param action
* the action being attempted which this assertion is applied, for debugging purposes.
* @throws ServiceException
*/
protected void assertValidObject(StorageObject object, String action) throws ServiceException {
if (object == null || object.getKey() == null || object.getKey().length() == 0) {
throw new ServiceException("The action " + action
+ " cannot be performed with an invalid object: " + object);
}
}