S3Object object = new S3Object(objectKey); if (offset < partCount - 1) { object.setContentLength(maxPartSize); segFIS = new SegmentedRepeatableFileInputStream( file, offset * maxPartSize, maxPartSize); partLength = maxPartSize; object.setContentLength(partLength); segFIS = new SegmentedRepeatableFileInputStream( file, offset * maxPartSize, partLength); object.setContentLength(segFIS.available()); object.setDataInputStream(segFIS);
S3Object object = new S3Object(objectKey); if (offset < partCount - 1) { object.setContentLength(maxPartSize); segFIS = new SegmentedRepeatableFileInputStream( file, offset * maxPartSize, maxPartSize); partLength = maxPartSize; object.setContentLength(partLength); segFIS = new SegmentedRepeatableFileInputStream( file, offset * maxPartSize, partLength); object.setContentLength(segFIS.available()); object.setDataInputStream(segFIS);
/** * * @param containerName * @param objectName * @param is * @throws StorageCommunicationException * @see org.opencredo.cloud.storage.StorageOperations#send(java.lang.String, * java.lang.String, java.io.InputStream) */ public void send(String containerName, String objectName, InputStream is) throws StorageCommunicationException { Assert.notNull(containerName, "Bucket name cannot be null"); Assert.hasText(objectName, "Blob name must be set"); LOG.debug("Send input-stream to bucket '{}' with key '{}'", containerName, objectName); try { S3Object s3ObjectToSend = new S3Object(objectName); s3ObjectToSend.setDataInputStream(is); s3ObjectToSend.setContentLength(is.available()); s3Service.putObject(new S3Bucket(containerName), s3ObjectToSend); } catch (IOException e) { throw new StorageCommunicationException("Sending input stream IO problem", e); } catch (S3ServiceException e) { throw new StorageCommunicationException("Sending input stream problem", e); } }
s3o.setContentLength(file.length()); s3o.setDataInputStream(new BufferedInputStream(new FileInputStream(file))); s3o.setContentType("application/gzip");
@Override public void storeEmptyFile(String key) throws IOException { try { S3Object object = new S3Object(key); object.setDataInputStream(new ByteArrayInputStream(new byte[0])); object.setContentType("binary/octet-stream"); object.setContentLength(0); object.setServerSideEncryptionAlgorithm(serverSideEncryptionAlgorithm); s3Service.putObject(bucket, object); } catch (ServiceException e) { handleException(e, key); } }
public void storeFile(String key, File file, byte[] md5Hash) throws IOException { BufferedInputStream in = null; try { in = new BufferedInputStream(new FileInputStream(file)); S3Object object = new S3Object(key); object.setDataInputStream(in); object.setContentType("binary/octet-stream"); object.setContentLength(file.length()); if (md5Hash != null) { object.setMd5Hash(md5Hash); } s3Service.putObject(bucket, object); } catch (S3ServiceException e) { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } throw new S3Exception(e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { // ignore } } } }
public void storeFile(String key, File file, byte[] md5Hash) throws IOException { BufferedInputStream in = null; try { in = new BufferedInputStream(new FileInputStream(file)); S3Object object = new S3Object(key); object.setDataInputStream(in); object.setContentType("binary/octet-stream"); object.setContentLength(file.length()); if (md5Hash != null) { object.setMd5Hash(md5Hash); } s3Service.putObject(bucket, object); } catch (S3ServiceException e) { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } throw new S3Exception(e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { // ignore } } } }
@Override public void storeFile(String key, File file, byte[] md5Hash) throws IOException { if (multipartEnabled && file.length() >= multipartBlockSize) { storeLargeFile(key, file, md5Hash); return; } BufferedInputStream in = null; try { in = new BufferedInputStream(new FileInputStream(file)); S3Object object = new S3Object(key); object.setDataInputStream(in); object.setContentType("binary/octet-stream"); object.setContentLength(file.length()); object.setServerSideEncryptionAlgorithm(serverSideEncryptionAlgorithm); if (md5Hash != null) { object.setMd5Hash(md5Hash); } s3Service.putObject(bucket, object); } catch (ServiceException e) { handleException(e, key); } finally { IOUtils.closeStream(in); } }
public void storeEmptyFile(String key) throws IOException { try { S3Object object = new S3Object(key); object.setDataInputStream(new ByteArrayInputStream(new byte[0])); object.setContentType("binary/octet-stream"); object.setContentLength(0); s3Service.putObject(bucket, object); } catch (S3ServiceException e) { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } throw new S3Exception(e); } }
public void storeEmptyFile(String key) throws IOException { try { S3Object object = new S3Object(key); object.setDataInputStream(new ByteArrayInputStream(new byte[0])); object.setContentType("binary/octet-stream"); object.setContentLength(0); s3Service.putObject(bucket, object); } catch (S3ServiceException e) { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } throw new S3Exception(e); } }
public void storeLargeFile(String key, File file, byte[] md5Hash) throws IOException { S3Object object = new S3Object(key); object.setDataInputFile(file); object.setContentType("binary/octet-stream"); object.setContentLength(file.length()); object.setServerSideEncryptionAlgorithm(serverSideEncryptionAlgorithm); if (md5Hash != null) { object.setMd5Hash(md5Hash); } List<StorageObject> objectsToUploadAsMultipart = new ArrayList<StorageObject>(); objectsToUploadAsMultipart.add(object); MultipartUtils mpUtils = new MultipartUtils(multipartBlockSize); try { mpUtils.uploadObjects(bucket.getName(), s3Service, objectsToUploadAsMultipart, null); } catch (Exception e) { handleException(e, key); } }
s3Object.setContentLength(0); s3Object.setContentType(Mimetypes.MIMETYPE_BINARY_OCTET_STREAM); } else { File uploadFile = transformUploadFile(dataFile, s3Object, encryptionUtil, gzipFile, progressWatcher); s3Object.setContentLength(uploadFile.length()); s3Object.setDataInputFile(uploadFile);
s3Object.setDataInputStream(s3IS); s3Object.setContentType("binary/octet-stream"); s3Object.setContentLength(s3IS.available()); RestS3Service s3Service = null; try {
s3Object.setContentLength(0); s3Object.setContentType(Mimetypes.MIMETYPE_BINARY_OCTET_STREAM); } else { File uploadFile = transformUploadFile(dataFile, s3Object, encryptionUtil, gzipFile, progressWatcher); s3Object.setContentLength(uploadFile.length()); s3Object.setDataInputFile(uploadFile);
directoryObject.setContentLength(0); children[i] = FileFactory.getFile(childURL, parent, service, directoryObject); i++;
object.setContentLength(ObjectUtils.to(long.class, value));
object.setContentLength(objectLength);
private void put(String key, InputStream in, long length, boolean storeMetadata) throws IOException { try { S3Object object = new S3Object(key); object.setDataInputStream(in); object.setContentType("binary/octet-stream"); object.setContentLength(length); if (storeMetadata) { object.addAllMetadata(METADATA); } s3Service.putObject(bucket, object); } catch (S3ServiceException e) { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } throw new S3Exception(e); } }
private void put(String key, InputStream in, long length, boolean storeMetadata) throws IOException { try { S3Object object = new S3Object(key); object.setDataInputStream(in); object.setContentType("binary/octet-stream"); object.setContentLength(length); if (storeMetadata) { object.addAllMetadata(METADATA); } s3Service.putObject(bucket, object); } catch (S3ServiceException e) { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } throw new S3Exception(e); } }
private void put(String key, InputStream in, long length, boolean storeMetadata) throws IOException { try { S3Object object = new S3Object(key); object.setDataInputStream(in); object.setContentType("binary/octet-stream"); object.setContentLength(length); if (storeMetadata) { object.addAllMetadata(METADATA); } s3Service.putObject(bucket, object); } catch (S3ServiceException e) { if (e.getCause() instanceof IOException) { throw (IOException) e.getCause(); } throw new S3Exception(e); } }