public void deleteObject(String bucket, String key) { amazonS3.deleteObject(bucket, key); } }
private boolean deleteObject(String key) { try { s3.deleteObject(getBucketName(uri), key); return true; } catch (AmazonClientException e) { return false; } }
private static void deleteFile(ParameterTool params) { final String bucket = params.getRequired("bucket"); final String s3file = params.getRequired("s3file"); AmazonS3ClientBuilder.defaultClient().deleteObject(bucket, s3file); }
public static void main(String[] args) { final String USAGE = "\n" + "To run this example, supply the name of an S3 bucket and object\n" + "name (key) to delete.\n" + "\n" + "Ex: DeleteObject <bucketname> <objectname>\n"; if (args.length < 2) { System.out.println(USAGE); System.exit(1); } String bucket_name = args[0]; String object_key = args[1]; System.out.format("Deleting object %s from S3 bucket: %s\n", object_key, bucket_name); final AmazonS3 s3 = AmazonS3ClientBuilder.defaultClient(); try { s3.deleteObject(bucket_name, object_key); } catch (AmazonServiceException e) { System.err.println(e.getErrorMessage()); System.exit(1); } System.out.println("Done!"); } }
@Override public void removeImages(String merchantStoreCode) throws ServiceException { try { // get buckets String bucketName = bucketName(); final AmazonS3 s3 = s3Client(); s3.deleteObject(bucketName, nodePath(merchantStoreCode)); LOGGER.info("Remove folder"); } catch (final Exception e) { LOGGER.error("Error while removing folder", e); throw new ServiceException(e); } }
@Override public void removeFiles(String merchantStoreCode) throws ServiceException { try { // get buckets String bucketName = bucketName(); final AmazonS3 s3 = s3Client(); s3.deleteObject(bucketName, nodePath(merchantStoreCode)); LOGGER.info("Remove folder"); } catch (final Exception e) { LOGGER.error("Error while removing folder", e); throw new ServiceException(e); } }
@Override public void removeFile(String merchantStoreCode, FileContentType staticContentType, String fileName) throws ServiceException { try { // get buckets String bucketName = bucketName(); final AmazonS3 s3 = s3Client(); s3.deleteObject(bucketName, nodePath(merchantStoreCode, staticContentType) + fileName); LOGGER.info("Remove file"); } catch (final Exception e) { LOGGER.error("Error while removing file", e); throw new ServiceException(e); } }
@Override public void delete( UUID appId, Entity entity ) throws Exception { getS3Client().deleteObject(new DeleteObjectRequest(bucketName, AssetUtils.buildAssetKey( appId, entity ))); } }
/** {@inheritDoc} */ @Override public void unregisterAddresses(Collection<InetSocketAddress> addrs) throws IgniteSpiException { assert !F.isEmpty(addrs); initClient(); for (InetSocketAddress addr : addrs) { String key = key(addr); try { s3.deleteObject(bucketName, key); } catch (AmazonClientException e) { throw new IgniteSpiException("Failed to delete entry [bucketName=" + bucketName + ", entry=" + key + ']', e); } } }
/** * Deletes checkpoint data. * * @param key Key of the data in storage. * @return {@code True} if operations succeeds and data is actually removed. * @throws AmazonClientException If an error occurs while querying Amazon S3. */ private boolean delete(String key) throws AmazonClientException { assert !F.isEmpty(key); if (log.isDebugEnabled()) log.debug("Removing data from S3 [bucket=" + bucketName + ", key=" + key + ']'); if (!hasKey(key)) return false; s3.deleteObject(bucketName, key); return true; }
@Override public void removeProductImages(Product product) throws ServiceException { try { // get buckets String bucketName = bucketName(); final AmazonS3 s3 = s3Client(); s3.deleteObject(bucketName, nodePath(product.getMerchantStore().getCode(), product.getSku())); LOGGER.info("Remove file"); } catch (final Exception e) { LOGGER.error("Error while removing file", e); throw new ServiceException(e); } }
@Timed @GET @Produces(MediaType.APPLICATION_JSON) @Path("/form/avatar") public ProfileAvatarUploadAttributes getAvatarUploadForm(@Auth Account account) { String previousAvatar = account.getAvatar(); ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC); String objectName = generateAvatarObjectName(); Pair<String, String> policy = policyGenerator.createFor(now, objectName); String signature = policySigner.getSignature(now, policy.second()); if (previousAvatar != null && previousAvatar.startsWith("profiles/")) { s3client.deleteObject(bucket, previousAvatar); } account.setAvatar(objectName); accountsManager.update(account); return new ProfileAvatarUploadAttributes(objectName, policy.first(), "private", "AWS4-HMAC-SHA256", now.format(PostPolicyGenerator.AWS_DATE_TIME), policy.second(), signature); }
iterator.hasNext();) { S3ObjectSummary summary = (S3ObjectSummary)iterator.next(); s3.deleteObject(bucket_name, summary.getKey());
@Override public void removeProductImage(ProductImage productImage) throws ServiceException { try { // get buckets String bucketName = bucketName(); final AmazonS3 s3 = s3Client(); s3.deleteObject(bucketName, nodePath(productImage.getProduct().getMerchantStore().getCode(), productImage.getProduct().getSku()) + productImage.getProductImage()); LOGGER.info("Remove file"); } catch (final Exception e) { LOGGER.error("Error while removing file", e); throw new ServiceException(e); } }
final DeleteObjectRequest r = new DeleteObjectRequest(bucket, key); s3.deleteObject(r); } else { final DeleteVersionRequest r = new DeleteVersionRequest(bucket, key, versionId);
public static void deleteObject(final ClientOptions clientOptions, final String bucketName, final String key) { LOGGER.debug(format("Deleting S3 Object %1$s in bucket %2$s", key, bucketName)); getAmazonS3Client(clientOptions).deleteObject(bucketName,key); }
retry.retry(() -> amazonS3.deleteObject(bucket, path), MAX_RETRIES, RETRY_BACKOFF);
retry.retry(() -> amazonS3.deleteObject(bucket, originalPath), MAX_RETRIES, RETRY_BACKOFF);
private void deleteFile(AmazonS3 s3Client) throws IOException, InterruptedException { // See if the thing that we were given is a file. if (s3Client.doesObjectExist(bucket, path)) { Execution.this.getContext().get(TaskListener.class).getLogger().format("Deleting object at s3://%s/%s%n", bucket, path); s3Client.deleteObject(bucket, path); } } }.start();
@Override public void rename(String pathFrom, String pathTo) throws IOException { String[] bucketKeyFrom = splitPathToBucketAndKey(pathFrom, true); String[] bucketKeyTo = splitPathToBucketAndKey(pathTo, true); CopyObjectRequest copyRequest = new CopyObjectRequest(bucketKeyFrom[0], bucketKeyFrom[1], bucketKeyTo[0], bucketKeyTo[1]); this.amazonS3.copyObject(copyRequest); //Delete the source this.amazonS3.deleteObject(bucketKeyFrom[0], bucketKeyFrom[1]); }