@Override protected boolean createEmptyObject(String key) { try { GSObject obj = new GSObject(key); obj.setDataInputStream(new ByteArrayInputStream(new byte[0])); obj.setContentLength(0); obj.setMd5Hash(DIR_HASH); obj.setContentType(Mimetypes.MIMETYPE_BINARY_OCTET_STREAM); mClient.putObject(mBucketName, obj); return true; } catch (ServiceException e) { LOG.error("Failed to create directory: {}", key, e); return false; } }
@Override protected boolean createEmptyObject(String key) { try { GSObject obj = new GSObject(key); obj.setDataInputStream(new ByteArrayInputStream(new byte[0])); obj.setContentLength(0); obj.setMd5Hash(DIR_HASH); obj.setContentType(Mimetypes.MIMETYPE_BINARY_OCTET_STREAM); mClient.putObject(mBucketName, obj); return true; } catch (ServiceException e) { LOG.error("Failed to create directory: {}", key, e); return false; } }
public void writeBlankChunk(String hash, byte[] chunk) throws IOException { String hashString = hash; GSObject gsObject = new GSObject(hashString); if (Main.compress) { chunk = CompressionUtils.compressZLIB(chunk); gsObject.addMetadata("compress", "true"); } else { gsObject.addMetadata("compress", "false"); } if (Main.chunkStoreEncryptionEnabled) { chunk = EncryptUtils.encrypt(chunk); gsObject.addMetadata("encrypt", "true"); } else { gsObject.addMetadata("encrypt", "false"); } ByteArrayInputStream s3IS = new ByteArrayInputStream(chunk); gsObject.setDataInputStream(s3IS); gsObject.setContentType("binary/octet-stream"); gsObject.setContentLength(s3IS.available()); try { gsService.putObject(this.getName(), gsObject); } catch (Exception e) { // TODO Auto-generated catch block SDFSLogger.getLog().fatal("unable to upload " + hashString, e); throw new IOException(e); } finally { s3IS.close(); } }
gsObject.setDataInputStream(s3IS); gsObject.setContentType("binary/octet-stream"); gsObject.setContentLength(s3IS.available());
ByteArrayInputStream greetingIS = new ByteArrayInputStream( greeting.getBytes(Constants.DEFAULT_ENCODING)); helloWorldObject.setDataInputStream(greetingIS); helloWorldObject.setContentLength( greeting.getBytes(Constants.DEFAULT_ENCODING).length); hashObject.setDataInputStream(dataIS); hashObject.setMd5Hash(md5Hash);
ByteArrayInputStream greetingIS = new ByteArrayInputStream( greeting.getBytes(Constants.DEFAULT_ENCODING)); helloWorldObject.setDataInputStream(greetingIS); helloWorldObject.setContentLength( greeting.getBytes(Constants.DEFAULT_ENCODING).length); hashObject.setDataInputStream(dataIS); hashObject.setMd5Hash(md5Hash);