@Override public void fireProgressEvent(ThreadWatcher threadWatcher, List completedResults) { MultipartUpload[] completedObjects = (MultipartUpload[]) completedResults .toArray(new MultipartUpload[completedResults.size()]); // Hack way to remove completed objects from incomplete list List<StorageObject> completedStorageObjects = new ArrayList<StorageObject>(); for (MultipartUpload upload: completedObjects) { for (StorageObject object: incompletedObjectsList) { if (object.getKey().equals(upload.getObjectKey())) { completedStorageObjects.add(object); } } } incompletedObjectsList.removeAll(completedStorageObjects); fireServiceEvent(MultipartStartsEvent.newInProgressEvent(threadWatcher, completedObjects, uniqueOperationId)); } @Override
@Override public void fireProgressEvent(ThreadWatcher threadWatcher, List completedResults) { MultipartUpload[] completedObjects = (MultipartUpload[]) completedResults .toArray(new MultipartUpload[completedResults.size()]); // Hack way to remove completed objects from incomplete list List<StorageObject> completedStorageObjects = new ArrayList<StorageObject>(); for (MultipartUpload upload: completedObjects) { for (StorageObject object: incompletedObjectsList) { if (object.getKey().equals(upload.getObjectKey())) { completedStorageObjects.add(object); } } } incompletedObjectsList.removeAll(completedStorageObjects); fireServiceEvent(MultipartStartsEvent.newInProgressEvent(threadWatcher, completedObjects, uniqueOperationId)); } @Override
@Override public List<MultipartPart> list(final MultipartUpload multipart) throws BackgroundException { if(log.isInfoEnabled()) { log.info(String.format("List completed parts of %s", multipart.getUploadId())); } // This operation lists the parts that have been uploaded for a specific multipart upload. try { return session.getClient().multipartListParts(multipart); } catch(S3ServiceException e) { throw new S3ExceptionMappingService().map(MessageFormat.format("Upload {0} failed", multipart.getObjectKey()), e); } }
/** * Abort the given multipart upload process. Also deletes any parts that may * have already been uploaded. * * @param upload * the multipart upload to abort. * @throws S3ServiceException */ public void multipartAbortUpload(MultipartUpload upload) throws S3ServiceException { multipartAbortUploadImpl(upload.getUploadId(), upload.getBucketName(), upload.getObjectKey()); }
/** * Abort the given multipart upload process. Also deletes any parts that may * have already been uploaded. * * @param upload * the multipart upload to abort. * @throws S3ServiceException */ public void multipartAbortUpload(MultipartUpload upload) throws S3ServiceException { multipartAbortUploadImpl(upload.getUploadId(), upload.getBucketName(), upload.getObjectKey()); }
/** * List the parts that have been uploaded for a given multipart upload. * * @param upload * the multipart upload whose parts will be listed. * @return * a list of multipart parts that have been successfully uploaded. * @throws S3ServiceException */ public List<MultipartPart> multipartListParts(MultipartUpload upload) throws S3ServiceException { return multipartListPartsImpl(upload.getUploadId(), upload.getBucketName(), upload.getObjectKey()); }
/** * List the parts that have been uploaded for a given multipart upload. * * @param upload * the multipart upload whose parts will be listed. * @return * a list of multipart parts that have been successfully uploaded. * @throws S3ServiceException */ public List<MultipartPart> multipartListParts(MultipartUpload upload) throws S3ServiceException { return multipartListPartsImpl(upload.getUploadId(), upload.getBucketName(), upload.getObjectKey()); }
/** * Complete a multipart upload by combining all the given parts into * the final object. * * @param upload * the multipart upload whose parts will be completed. * @param parts * the parts comprising the final object. * @return * information about the completion operation. * @throws S3ServiceException */ public MultipartCompleted multipartCompleteUpload(MultipartUpload upload, List<MultipartPart> parts) throws S3ServiceException { return multipartCompleteUploadImpl(upload.getUploadId(), upload.getBucketName(), upload.getObjectKey(), parts); }
/** * Complete a multipart upload by combining all the given parts into * the final object. * * @param upload * the multipart upload whose parts will be completed. * @param parts * the parts comprising the final object. * @return * information about the completion operation. * @throws S3ServiceException */ public MultipartCompleted multipartCompleteUpload(MultipartUpload upload, List<MultipartPart> parts) throws S3ServiceException { return multipartCompleteUploadImpl(upload.getUploadId(), upload.getBucketName(), upload.getObjectKey(), parts); }
@Override public void delete(final MultipartUpload upload) throws BackgroundException { if(log.isInfoEnabled()) { log.info(String.format("Delete multipart upload %s", upload.getUploadId())); } try { session.getClient().multipartAbortUpload(upload); } catch(S3ServiceException e) { throw new S3ExceptionMappingService().map("Cannot delete {0}", e, new Path(new Path(PathNormalizer.normalize(upload.getBucketName()), EnumSet.of(Path.Type.directory)), upload.getObjectKey(), EnumSet.of(Path.Type.file))); } } }
@Override public String toString() { return this.getClass().getName() + " [" + "uploadId=" + getUploadId() + ", bucketName=" + getBucketName() + ", objectKey=" + getObjectKey() + (metadata != null ? ", metadata=" + getMetadata() : "") + (storageClass != null ? ", storageClass=" + getStorageClass() : "") + (initiator != null ? ", initiator=" + getInitiator() : "") + (owner != null ? ", owner=" + getOwner() : "") + (initiatedDate != null ? ", initiatedDate=" + getInitiatedDate() : "") + ", multipartsPartsUploaded=" + multipartsPartsUploaded + "]"; }
@Override public String toString() { return this.getClass().getName() + " [" + "uploadId=" + getUploadId() + ", bucketName=" + getBucketName() + ", objectKey=" + getObjectKey() + (metadata != null ? ", metadata=" + getMetadata() : "") + (storageClass != null ? ", storageClass=" + getStorageClass() : "") + (initiator != null ? ", initiator=" + getInitiator() : "") + (owner != null ? ", owner=" + getOwner() : "") + (initiatedDate != null ? ", initiatedDate=" + getInitiatedDate() : "") + ", multipartsPartsUploaded=" + multipartsPartsUploaded + "]"; }
/** * Convenience method to complete a multipart upload by automatically finding * its parts. This method does more work than the lower-level * {@link #multipartCompleteUpload(MultipartUpload, List)} API operation, but * relieves the caller of having to keep track of all the parts uploaded * for a multipart upload. * * @param upload * the multipart upload whose parts will be completed. * @return * information about the completion operation. * @throws S3ServiceException */ public MultipartCompleted multipartCompleteUpload(MultipartUpload upload) throws S3ServiceException { List<MultipartPart> parts = multipartListParts(upload); return multipartCompleteUploadImpl(upload.getUploadId(), upload.getBucketName(), upload.getObjectKey(), parts); }
/** * Convenience method to complete a multipart upload by automatically finding * its parts. This method does more work than the lower-level * {@link #multipartCompleteUpload(MultipartUpload, List)} API operation, but * relieves the caller of having to keep track of all the parts uploaded * for a multipart upload. * * @param upload * the multipart upload whose parts will be completed. * @return * information about the completion operation. * @throws S3ServiceException */ public MultipartCompleted multipartCompleteUpload(MultipartUpload upload) throws S3ServiceException { List<MultipartPart> parts = multipartListParts(upload); return multipartCompleteUploadImpl(upload.getUploadId(), upload.getBucketName(), upload.getObjectKey(), parts); }
/** * From an existing object, copy an individual part that will comprise a piece of a * multipart upload object. * * @param upload * the multipart upload to which this part will be added. * @param partNumber * the part's number; must be between 1 and 10,000 and must uniquely identify a given * part and represent its order compared to all other parts. Part numbers need not * be sequential. * @param sourceBucketName * the name of the bucket that contains the original object. * @param sourceObjectKey * the key name of the original object. * * @return * information about the uploaded copy part, retain this information to eventually complete * the object with {@link #multipartCompleteUpload(MultipartUpload, List)}. * @throws S3ServiceException */ public MultipartPart multipartUploadPartCopy(MultipartUpload upload, Integer partNumber, String sourceBucketName, String sourceObjectKey) throws S3ServiceException { MultipartPart part = multipartUploadPartCopyImpl(upload.getUploadId(), upload.getBucketName(), upload.getObjectKey(), partNumber, sourceBucketName, sourceObjectKey, null, null, null, null, null, null, null); upload.addMultipartPartToUploadedList(part); return part; }
/** * From an existing object, copy an individual part that will comprise a piece of a * multipart upload object. * * @param upload * the multipart upload to which this part will be added. * @param partNumber * the part's number; must be between 1 and 10,000 and must uniquely identify a given * part and represent its order compared to all other parts. Part numbers need not * be sequential. * @param sourceBucketName * the name of the bucket that contains the original object. * @param sourceObjectKey * the key name of the original object. * * @return * information about the uploaded copy part, retain this information to eventually complete * the object with {@link #multipartCompleteUpload(MultipartUpload, List)}. * @throws S3ServiceException */ public MultipartPart multipartUploadPartCopy(MultipartUpload upload, Integer partNumber, String sourceBucketName, String sourceObjectKey) throws S3ServiceException { MultipartPart part = multipartUploadPartCopyImpl(upload.getUploadId(), upload.getBucketName(), upload.getObjectKey(), partNumber, sourceBucketName, sourceObjectKey, null, null, null, null, null, null, null); upload.addMultipartPartToUploadedList(part); return part; }
upload.getBucketName(), upload.getObjectKey(), partNumber, sourceBucketName, sourceObjectKey, null, null, null, null, null, null, versionId);
upload.getBucketName(), upload.getObjectKey(), partNumber, sourceBucketName, sourceObjectKey, null, null, null, null, null, null, versionId);
@Override public HttpResponseOutputStream<VersionId> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException { final S3Object object = new S3WriteFeature(session, new S3DisabledMultipartService()) .getDetails(file, status); // ID for the initiated multipart upload. final MultipartUpload multipart; try { multipart = session.getClient().multipartStartUpload( containerService.getContainer(file).getName(), object); if(log.isDebugEnabled()) { log.debug(String.format("Multipart upload started for %s with ID %s", multipart.getObjectKey(), multipart.getUploadId())); } } catch(ServiceException e) { throw new S3ExceptionMappingService().map("Upload {0} failed", e, file); } final MultipartOutputStream proxy = new MultipartOutputStream(multipart, file, status); return new HttpResponseOutputStream<VersionId>(new MemorySegementingOutputStream(proxy, preferences.getInteger("s3.upload.multipart.partsize.minimum"))) { @Override public VersionId getStatus() { return proxy.getVersionId(); } }; }
attributes.setVersionId(upload.getUploadId()); attributes.setModificationDate(upload.getInitiatedDate().getTime()); objects.add(new Path(directory, upload.getObjectKey(), EnumSet.of(Path.Type.file, Path.Type.upload), attributes));