public String putBlob(String container, Blob blob) { try { String name = FilenameUtils.getName(blob.getMetadata().getName()); String path = FilenameUtils.getPathNoEndSeparator(blob.getMetadata().getName()); service.uploadInputStream( blob.getPayload().getInput(), container, path, name, blob.getPayload().getContentMetadata().getContentLength()); return null; } catch (UploadException e) { e.printStackTrace(); return null; } catch (MethodNotSupportedException e) { e.printStackTrace(); return null; } catch (FileNotExistsException e) { e.printStackTrace(); return null; } }
public BlobMetadata blobMetadata(String container, String name) { try { StorageObject storageObject = service.getStorageObject(container, name); return generateJcloudsMetadata(storageObject.getMetadata()); } catch (FileNotExistsException e) { e.printStackTrace(); return null; } }
public Blob getBlob(String container, String name) { try { StorageObject storageObject = service.getStorageObject(container, name); Blob blob = new BlobImpl(generateJcloudsMetadata(storageObject.getMetadata())); if (storageObject.getStream() != null) { blob.setPayload(storageObject.getStream()); blob.getMetadata() .getContentMetadata() .setContentLength(storageObject.getMetadata().getLength()); } return blob; } catch (FileNotExistsException e) { e.printStackTrace(); return null; } }