public static String putBlob(final AtmosClient sync, Crypto crypto, BlobToObject blob2Object, String container, Blob blob, PutOptions options) { final String path = container + "/" + blob.getMetadata().getName(); final AtmosObject object = blob2Object.apply(blob); try { sync.createFile(container, object, options); } catch (KeyAlreadyExistsException e) { deletePathAndEnsureGone(sync, path); sync.createFile(container, object, options); } return path; }
public static String putBlob(final AtmosClient sync, Crypto crypto, BlobToObject blob2Object, String container, Blob blob, PutOptions options) { final String path = container + "/" + blob.getMetadata().getName(); final AtmosObject object = blob2Object.apply(blob); URI uri; try { uri = sync.createFile(container, object, options); } catch (KeyAlreadyExistsException e) { deletePathAndEnsureGone(sync, path); uri = sync.createFile(container, object, options); } // return object ID as the ETag String objectId = uri.getPath(); String prefix = "/rest/objects/"; checkState(objectId.startsWith(prefix), objectId); return objectId.substring(prefix.length()); }
public static String putBlob(final AtmosClient sync, Crypto crypto, BlobToObject blob2Object, String container, Blob blob, PutOptions options) { final String path = container + "/" + blob.getMetadata().getName(); final AtmosObject object = blob2Object.apply(blob); try { sync.createFile(container, object, options); } catch(KeyAlreadyExistsException e) { deletePathAndEnsureGone(sync, path); sync.createFile(container, object, options); } return path; }
public static String putBlob(final AtmosClient sync, Crypto crypto, BlobToObject blob2Object, String container, Blob blob, PutOptions options) { final String path = container + "/" + blob.getMetadata().getName(); final AtmosObject object = blob2Object.apply(blob); try { sync.createFile(container, object, options); } catch(KeyAlreadyExistsException e) { deletePathAndEnsureGone(sync, path); sync.createFile(container, object, options); } return path; }
public static String putBlob(final AtmosClient sync, Crypto crypto, BlobToObject blob2Object, String container, Blob blob, PutOptions options) { final String path = container + "/" + blob.getMetadata().getName(); final AtmosObject object = blob2Object.apply(blob); try { sync.createFile(container, object, options); } catch (KeyAlreadyExistsException e) { deletePathAndEnsureGone(sync, path); sync.createFile(container, object, options); } return path; }
public static String putBlob(final AtmosClient sync, Crypto crypto, BlobToObject blob2Object, String container, Blob blob, PutOptions options) { final String path = container + "/" + blob.getMetadata().getName(); final AtmosObject object = blob2Object.apply(blob); URI uri; try { uri = sync.createFile(container, object, options); } catch (KeyAlreadyExistsException e) { deletePathAndEnsureGone(sync, path); uri = sync.createFile(container, object, options); } // return object ID as the ETag String objectId = uri.getPath(); String prefix = "/rest/objects/"; checkState(objectId.startsWith(prefix), objectId); return objectId.substring(prefix.length()); }
public static String putBlob(final AtmosClient sync, Crypto crypto, BlobToObject blob2Object, String container, Blob blob, PutOptions options) { final String path = container + "/" + blob.getMetadata().getName(); final AtmosObject object = blob2Object.apply(blob); try { sync.createFile(container, object, options); } catch (KeyAlreadyExistsException e) { deletePathAndEnsureGone(sync, path); sync.createFile(container, object, options); } return path; }
private void alwaysDeleteFirstReplaceStrategy(AtmosObject object) throws Exception { deleteConfirmed(privateDirectory + "/" + object.getContentMetadata().getName()); long time = System.currentTimeMillis(); try { getApi().createFile(privateDirectory, object); System.err.printf("%s %s; %dms%n", "created", object.getPayload() instanceof InputStreamPayload ? "stream" : "string", System.currentTimeMillis() - time); } catch (Exception e) { String message = Throwables.getRootCause(e).getMessage(); System.err.printf("failure %s %s; %dms: [%s]%n", "creating", object.getPayload() instanceof InputStreamPayload ? "stream" : "string", System.currentTimeMillis() - time, message); throw e; } }
private void alwaysDeleteFirstReplaceStrategy(AtmosObject object) throws Exception { deleteConfirmed(privateDirectory + "/" + object.getContentMetadata().getName()); long time = System.currentTimeMillis(); try { getApi().createFile(privateDirectory, object); System.err.printf("%s %s; %dms%n", "created", object.getPayload() instanceof InputStreamPayload ? "stream" : "string", System.currentTimeMillis() - time); } catch (Exception e) { String message = Throwables.getRootCause(e).getMessage(); System.err.printf("failure %s %s; %dms: [%s]%n", "creating", object.getPayload() instanceof InputStreamPayload ? "stream" : "string", System.currentTimeMillis() - time, message); throw e; } }
private void checkSystemMetadataAndPutIfPresentReplaceStrategy(AtmosObject object) throws Exception { long time = System.currentTimeMillis(); boolean update = true; try { getApi().getSystemMetadata(privateDirectory + "/object"); } catch (KeyNotFoundException ex) { update = false; } try { if (update) getApi().updateFile(privateDirectory, object); else getApi().createFile(privateDirectory, object); System.err.printf("%s %s; %dms%n", update ? "updated" : "created", object.getPayload() instanceof InputStreamPayload ? "stream" : "string", System.currentTimeMillis() - time); } catch (Exception e) { String message = Throwables.getRootCause(e).getMessage(); System.err.printf("failure %s %s; %dms: [%s]%n", update ? "updating" : "creating", object.getPayload() instanceof InputStreamPayload ? "stream" : "string", System.currentTimeMillis() - time, message); throw e; } } }
private void checkSystemMetadataAndPutIfPresentReplaceStrategy(AtmosObject object) throws Exception { long time = System.currentTimeMillis(); boolean update = true; try { getApi().getSystemMetadata(privateDirectory + "/object"); } catch (KeyNotFoundException ex) { update = false; } try { if (update) getApi().updateFile(privateDirectory, object); else getApi().createFile(privateDirectory, object); System.err.printf("%s %s; %dms%n", update ? "updated" : "created", object.getPayload() instanceof InputStreamPayload ? "stream" : "string", System.currentTimeMillis() - time); } catch (Exception e) { String message = Throwables.getRootCause(e).getMessage(); System.err.printf("failure %s %s; %dms: [%s]%n", update ? "updating" : "creating", object.getPayload() instanceof InputStreamPayload ? "stream" : "string", System.currentTimeMillis() - time, message); throw e; } } }