storage.objects().delete(bucketName, item.getName()).execute();
@Override public void addDelete( StorageObject storageObject, RpcBatch.Callback<Void> callback, Map<Option, ?> options) { try { if (currentBatchSize == MAX_BATCH_SIZE) { batches.add(storage.batch()); currentBatchSize = 0; } deleteCall(storageObject, options).queue(batches.getLast(), toJsonCallback(callback)); currentBatchSize++; } catch (IOException ex) { throw translate(ex); } }
try { for (final Tuple<StorageObject, Map<Option, ?>> tuple : request.toDelete) { deleteRequest(tuple.x(), tuple.y()).queue(batch, new JsonBatchCallback<Void>() { @Override public void onSuccess(Void ignore, HttpHeaders responseHeaders) {
Storage.Objects.Delete deleteObject = configureRequest(gcs.objects().delete(bucketName, objectName), bucketName) .setIfGenerationMatch(generationId); batchHelper.queue( deleteObject,
while (!done && retryCount > 0) { try { storage.delete(destPath.getBucket(), shardToDelete).execute(); done = true; } catch (Exception ex) {
.objects() .delete(projectName + "-cloud-pubsub-loadtest", filePath.getFileName().toString()) .execute(); } catch (GoogleJsonResponseException e) { if (e.getStatusCode() != NOT_FOUND) {
while (!done && retryCount > 0) { try { storage.delete(destPath.getBucket(), shardToDelete).execute(); done = true; } catch (Exception ex) {
private void enqueueDelete(final GcsPath file, BatchRequest batch) throws IOException { Storage.Objects.Delete deleteRequest = storageClient.objects().delete(file.getBucket(), file.getObject()); deleteRequest.queue( batch, new JsonBatchCallback<Void>() { @Override public void onSuccess(Void obj, HttpHeaders responseHeaders) { LOG.debug("Successfully deleted {}", file); } @Override public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) throws IOException { if (e.getCode() == 404) { LOG.info( "Ignoring failed deletion of file {} which already does not exist: {}", file, e); } else { throw new IOException(String.format("Error trying to delete %s: %s", file, e)); } } }); }
@Override public boolean delete(StorageObject blob, Map<Option, ?> options) { Span span = startSpan(HttpStorageRpcSpans.SPAN_NAME_DELETE_OBJECT); Scope scope = tracer.withSpan(span); try { deleteCall(blob, options).execute(); return true; } catch (IOException ex) { span.setStatus(Status.UNKNOWN.withDescription(ex.getMessage())); StorageException serviceException = translate(ex); if (serviceException.getCode() == HTTP_NOT_FOUND) { return false; } throw serviceException; } finally { scope.close(); span.end(); } }
/** * Delete single file test output. * * @param outputPath path to the output file to be deleted. * @throws Exception */ public void deleteOutput(String outputPath) throws Exception { // boilerplate GcsPath path = GcsPath.fromUri(outputPath); GcsOptions gcsOptions = popts.as(GcsOptions.class); Storage storage = Transport.newStorageClient(gcsOptions).build(); // do the actual work storage.objects().delete(path.getBucket(), path.getObject()).execute(); }
/** * Deletes a file within a bucket * * @param bucketName * Name of bucket that contains the file * @param fileName * The file to delete * @throws Exception */ public static void deleteFile(String bucketName, String fileName) throws Exception { Storage storage = getStorage(); storage.objects().delete(bucketName, fileName).execute(); }
List<StorageObject> storageObjects = new ArrayList(); torage.Objects.List listObjects = storage.objects().list(bucket); Objects objects = listObjects.execute(); storageObjects.addAll(objects.getItems()); for (StorageObject storageObject : workBucketObjects) { Storage.Objects.Delete delete = storage.objects().delete(bucketName,storageObject.getName()); delete.execute();
@Override public void addDelete( StorageObject storageObject, RpcBatch.Callback<Void> callback, Map<Option, ?> options) { try { if (currentBatchSize == MAX_BATCH_SIZE) { batches.add(storage.batch()); currentBatchSize = 0; } deleteCall(storageObject, options).queue(batches.getLast(), toJsonCallback(callback)); currentBatchSize++; } catch (IOException ex) { throw translate(ex); } }
@Override public boolean delete(StorageObject blob, Map<Option, ?> options) { try { deleteRequest(blob, options).execute(); return true; } catch (IOException ex) { StorageException serviceException = translate(ex); if (serviceException.code() == HTTP_NOT_FOUND) { return false; } throw serviceException; } }
private Storage.Objects.Delete deleteRequest(StorageObject blob, Map<Option, ?> options) throws IOException { return storage.objects() .delete(blob.getBucket(), blob.getName()) .setGeneration(blob.getGeneration()) .setIfMetagenerationMatch(IF_METAGENERATION_MATCH.getLong(options)) .setIfMetagenerationNotMatch(IF_METAGENERATION_NOT_MATCH.getLong(options)) .setIfGenerationMatch(IF_GENERATION_MATCH.getLong(options)) .setIfGenerationNotMatch(IF_GENERATION_NOT_MATCH.getLong(options)); }
private Storage.Objects.Delete deleteCall(StorageObject blob, Map<Option, ?> options) throws IOException { return storage .objects() .delete(blob.getBucket(), blob.getName()) .setGeneration(blob.getGeneration()) .setIfMetagenerationMatch(Option.IF_METAGENERATION_MATCH.getLong(options)) .setIfMetagenerationNotMatch(Option.IF_METAGENERATION_NOT_MATCH.getLong(options)) .setIfGenerationMatch(Option.IF_GENERATION_MATCH.getLong(options)) .setIfGenerationNotMatch(Option.IF_GENERATION_NOT_MATCH.getLong(options)) .setUserProject(Option.USER_PROJECT.getString(options)); }
@Override public void onSuccess(StorageObject storageObject, HttpHeaders httpHeaders) throws IOException { final Long generation = storageObject.getGeneration(); Storage.Objects.Delete deleteObject = configureRequest(gcs.objects().delete(bucketName, objectName), bucketName) .setIfGenerationMatch(generation); batchHelper.queue( deleteObject, getDeletionCallback( resourceId, innerExceptions, batchHelper, attempt, generation)); }
storage.objects().delete(bucketName, originalItem.getName()).execute();