/** * Returns an object representing the details and data of an item in a service, * without applying any preconditions. * <p> * This method can be performed by anonymous services. Anonymous services * can get a publicly-readable object. * <p> * <b>Important:</b> It is the caller's responsibility to close the object's data input stream. * The data stream should be consumed and closed as soon as is practical as network connections * may be held open until the streams are closed. Excessive unclosed streams can lead to * connection starvation. * * @param bucketName * the name of the bucket containing the object. * @param objectKey * the key identifying the object. * @return * the object with the given key, including the object's data input stream. * @throws ServiceException */ public StorageObject getObject(String bucketName, String objectKey) throws ServiceException { return getObject(bucketName, objectKey, null, null, null, null, null, null); }
/** * Returns an object representing the details of an item in without the object's data, and * without applying any preconditions. * <p> * This method can be performed by anonymous services. Anonymous services * can get a publicly-readable object's details. * * @param bucketName * the name of the bucket containing the object. * @param objectKey * the key identifying the object. * @return * the object with the given key, including only general details and metadata * (not the data input stream) * @throws ServiceException */ public StorageObject getObjectDetails(String bucketName, String objectKey) throws ServiceException { return getObjectDetails(bucketName, objectKey, null, null, null, null); }
/** * Returns the owner of an account, using information available in the * bucket listing response. * <p> * This method cannot be performed by anonymous services, and will fail with an exception * if the service is not authenticated. * * @return * the owner of the account. * @throws ServiceException */ public StorageOwner getAccountOwner() throws ServiceException { assertAuthenticatedConnection("List all buckets to find account owner"); return getAccountOwnerImpl(); }
/** * Returns a bucket in your account, and creates the bucket if * it does not yet exist. * * @param bucketName * the name of the bucket to retrieve or create. * @return * the bucket in your account. * * @throws ServiceException */ public StorageBucket getOrCreateBucket(String bucketName) throws ServiceException { StorageBucket bucket = getBucket(bucketName); if (bucket == null) { // Bucket does not exist in this user's account, create it. bucket = createBucket(bucketName); } return bucket; }
/** * Deletes a bucket. Only the owner of a bucket may delete it. * <p> * This method cannot be performed by anonymous services. * * @param bucket * the bucket to delete. * @throws ServiceException */ public void deleteBucket(StorageBucket bucket) throws ServiceException { assertValidBucket(bucket, "Delete bucket"); deleteBucketImpl(bucket.getName()); }
if (storageService.getProviderCredentials() == null) { bucket = storageService.getBucket(bucketName); } catch (ServiceException e) { bucket = storageService.createBucket(new StorageBucket(bucketName)); } catch (ServiceException e) { storageService.listObjectsChunked(bucketName, null, null, 1, null, false);
public void run() { try { if (headOnly) { result = storageService.getObjectDetails( bucketName, objectKey, null, null, null, null); } else { result = storageService.getObject( bucketName, objectKey); } } catch (ServiceException e) { if (this.errorPermitter != null && this.errorPermitter.isPermitted(e)) { result = new ThrowableBearingStorageObject(this.objectKey, e); } else { result = e; } } }
service.createBucket(bucketName[0]); service.putObject(bucketName[0], encryptedCredentialsObject);
/** * Lists the buckets belonging to the service user. * <p> * This method cannot be performed by anonymous services, and will fail with an exception * if the service is not authenticated. * * @return * the list of buckets owned by the service user. * @throws ServiceException */ public StorageBucket[] listAllBuckets() throws ServiceException { assertAuthenticatedConnection("List all buckets"); StorageBucket[] buckets = listAllBucketsImpl(); MxDelegate.getInstance().registerStorageBucketMBeans(buckets); return buckets; }
/** * Deletes an object from a bucket. * <p> * This method can be performed by anonymous services. Anonymous services * can delete objects from publicly-writable buckets. * * @param bucketName * the name of the bucket containing the object to be deleted. * @param objectKey * the key representing the object * @throws ServiceException */ public void deleteObject(String bucketName, String objectKey) throws ServiceException { assertValidObject(objectKey, "deleteObject"); MxDelegate.getInstance().registerStorageObjectDeleteEvent(bucketName, objectKey); deleteObjectImpl(bucketName, objectKey, null, null, null); }
/** * Applies access control settings to a bucket. The ACL settings must be included * inside the bucket. * * This method can be performed by anonymous services, but can only succeed if the * bucket's existing ACL already allows write access by the anonymous user. * In general, you can only access the ACL of a bucket if the ACL already in place * for that bucket allows you to do so. * * @param bucket * a bucket with ACL settings to apply. * @throws ServiceException */ public void putBucketAcl(StorageBucket bucket) throws ServiceException { assertValidBucket(bucket, "Put Bucket Access Control List"); putBucketAcl(bucket.getName(), bucket.getAcl()); }
/** * Applies access control settings to an object. The ACL settings must be included * with the object. * * This method can be performed by anonymous services, but can only succeed if the * object's existing ACL already allows write access by the anonymous user. * In general, you can only access the ACL of an object if the ACL already in place * for that object allows you to do so. * * @param bucketName * the name of the bucket containing the object to modify. * @param object * the object with ACL settings that will be applied. * @throws ServiceException */ public void putObjectAcl(String bucketName, StorageObject object) throws ServiceException { assertValidObject(object, "Put Object Access Control List"); putObjectAcl(bucketName, object.getKey(), object.getAcl()); }
/** * Returns a bucket in your account by listing all your buckets * (using {@link #listAllBuckets()}), and looking for the named bucket in * this list. * <p> * This method cannot be performed by anonymous services. * * @param bucketName * @return * the bucket in your account, or null if you do not own the named bucket. * * @throws ServiceException */ public StorageBucket getBucket(String bucketName) throws ServiceException { assertAuthenticatedConnection("Get Bucket"); // List existing buckets and return the named bucket if it exists. StorageBucket[] existingBuckets = listAllBuckets(); for (int i = 0; i < existingBuckets.length; i++) { if (existingBuckets[i].getName().equals(bucketName)) { return existingBuckets[i]; } } return null; }
/** * Puts an object inside an existing bucket, creating a new object or overwriting * an existing one with the same key. The Access Control List settings of the object * (if any) will also be applied. * <p> * This method can be performed by anonymous services. Anonymous services * can put objects into a publicly-writable bucket. * * @param bucketName * the name of the bucket inside which the object will be put. * @param object * the object containing all information that will be written to the service. * At very least this object must be valid. Beyond that it may contain: an input stream * with the object's data content, metadata, and access control settings. * <p> * <b>Note:</b> It is very important to set the object's Content-Length to match the size of the * data input stream when possible, as this can remove the need to read data into memory to * determine its size. * * @return * the object populated with any metadata. * @throws ServiceException */ public StorageObject putObject(String bucketName, StorageObject object) throws ServiceException { assertValidObject(object, "Create Object in bucket " + bucketName); MxDelegate.getInstance().registerStorageObjectPutEvent(bucketName, object.getKey()); return putObjectImpl(bucketName, object); }
boolean replaceMetadata) throws ServiceException Map<String, Object> copyResult = copyObject(sourceBucketName, sourceObjectKey, destinationBucketName, destinationObject, replaceMetadata); deleteObject(sourceBucketName, sourceObjectKey); } catch (Exception e) { copyResult.put("DeleteException", e);
String[] ifNoneMatchTags) throws ServiceException assertAuthenticatedConnection("copyObject"); Map<String, Object> destinationMetadata = replaceMetadata ? destinationObject.getModifiableMetadata() : null; return copyObjectImpl(sourceBucketName, sourceObjectKey, destinationBucketName, destinationObject.getKey(), destinationObject.getAcl(), destinationMetadata,
@Override public Void call() throws Exception { final StorageObject object = new StorageObject(logFile); object.setKey(taskKey); service.putObject(config.getS3Bucket(), object); return null; } }
public void run() { try { result = storageService.copyObject(sourceBucketName, sourceObjectKey, destinationBucketName, destinationObject, replaceMetadata); } catch (ServiceException e) { result = e; } }
/** * Creates a bucket. * * <b>Caution:</b> Performing this operation unnecessarily when a bucket already * exists may cause OperationAborted errors with the message "A conflicting conditional * operation is currently in progress against this resource.". To avoid this error, use the * {@link #getOrCreateBucket(String)} in situations where the bucket may already exist. * * This method cannot be performed by anonymous services. * * @param bucketName * the name of the bucket to create. * @return * the created bucket object. <b>Note:</b> the object returned has minimal information about * the bucket that was created, including only the bucket's name. * @throws ServiceException */ public StorageBucket createBucket(String bucketName) throws ServiceException { return createBucketImpl(bucketName, null, null); }
public void run() { try { result = storageService.createBucket(bucketName); } catch (ServiceException e) { result = e; } }