Search in sources :

Example 1 with MemorySegementingOutputStream

use of ch.cyberduck.core.io.MemorySegementingOutputStream in project cyberduck by iterate-ch.

the class BoxMultipartWriteFeature method write.

@Override
public HttpResponseOutputStream<File> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
    final UploadSession uploadSession = new BoxUploadHelper(session, fileid).createUploadSession(status, file);
    if (log.isDebugEnabled()) {
        log.debug(String.format("Obtained session %s for file %s", uploadSession, file));
    }
    final BoxOutputStream proxy = new BoxOutputStream(file, uploadSession, status);
    return new HttpResponseOutputStream<File>(new MemorySegementingOutputStream(proxy, uploadSession.getPartSize().intValue()), new BoxAttributesFinderFeature(session, fileid), status) {

        @Override
        public File getStatus() {
            return proxy.getResult();
        }
    };
}
Also used : MemorySegementingOutputStream(ch.cyberduck.core.io.MemorySegementingOutputStream) UploadSession(ch.cyberduck.core.box.io.swagger.client.model.UploadSession) HttpResponseOutputStream(ch.cyberduck.core.http.HttpResponseOutputStream)

Example 2 with MemorySegementingOutputStream

use of ch.cyberduck.core.io.MemorySegementingOutputStream in project cyberduck by iterate-ch.

the class SwiftLargeUploadWriteFeature method write.

@Override
public HttpResponseOutputStream<StorageObject> write(final Path file, final TransferStatus status, final ConnectionCallback callback) {
    final LargeUploadOutputStream proxy = new LargeUploadOutputStream(file, status);
    return new HttpResponseOutputStream<StorageObject>(new MemorySegementingOutputStream(proxy, new HostPreferences(session.getHost()).getInteger("openstack.upload.largeobject.size.minimum")), new SwiftAttributesFinderFeature(session, regionService), status) {

        @Override
        public StorageObject getStatus() {
            final StorageObject stored = new StorageObject(containerService.getKey(file));
            stored.setSize(status.getLength());
            stored.setMd5sum(proxy.getResponse());
            return stored;
        }
    };
}
Also used : StorageObject(ch.iterate.openstack.swift.model.StorageObject) MemorySegementingOutputStream(ch.cyberduck.core.io.MemorySegementingOutputStream) HttpResponseOutputStream(ch.cyberduck.core.http.HttpResponseOutputStream) HostPreferences(ch.cyberduck.core.preferences.HostPreferences)

Example 3 with MemorySegementingOutputStream

use of ch.cyberduck.core.io.MemorySegementingOutputStream in project cyberduck by iterate-ch.

the class StoregateMultipartWriteFeature method write.

@Override
public HttpResponseOutputStream<FileMetadata> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
    final String location = new StoregateWriteFeature(session, fileid).start(file, status);
    final MultipartOutputStream proxy = new MultipartOutputStream(location, file, status);
    return new HttpResponseOutputStream<FileMetadata>(new MemorySegementingOutputStream(proxy, new HostPreferences(session.getHost()).getInteger("storegate.upload.multipart.chunksize")), new StoregateAttributesFinderFeature(session, fileid), status) {

        @Override
        public FileMetadata getStatus() {
            return proxy.getResult();
        }
    };
}
Also used : MemorySegementingOutputStream(ch.cyberduck.core.io.MemorySegementingOutputStream) HttpResponseOutputStream(ch.cyberduck.core.http.HttpResponseOutputStream) HostPreferences(ch.cyberduck.core.preferences.HostPreferences)

Example 4 with MemorySegementingOutputStream

use of ch.cyberduck.core.io.MemorySegementingOutputStream in project cyberduck by iterate-ch.

the class GraphWriteFeature method write.

@Override
public StatusOutputStream<Void> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
    try {
        if (status.getLength() == TransferStatus.UNKNOWN_LENGTH) {
            throw new UnsupportedException("Content-Range with unknown file size is not supported");
        }
        final DriveItem folder = session.getItem(file.getParent());
        final DriveItem item = new DriveItem(folder, URIEncoder.encode(file.getName()));
        final UploadSession upload = Files.createUploadSession(item);
        final ChunkedOutputStream proxy = new ChunkedOutputStream(upload, file, status);
        final int partsize = new HostPreferences(session.getHost()).getInteger("onedrive.upload.multipart.partsize.minimum") * new HostPreferences(session.getHost()).getInteger("onedrive.upload.multipart.partsize.factor");
        return new VoidStatusOutputStream(new MemorySegementingOutputStream(proxy, partsize));
    } catch (OneDriveAPIException e) {
        throw new GraphExceptionMappingService(fileid).map("Upload {0} failed", e, file);
    } catch (IOException e) {
        throw new DefaultIOExceptionMappingService().map("Upload {0} failed", e, file);
    }
}
Also used : UnsupportedException(ch.cyberduck.core.exception.UnsupportedException) DriveItem(org.nuxeo.onedrive.client.types.DriveItem) OneDriveAPIException(org.nuxeo.onedrive.client.OneDriveAPIException) VoidStatusOutputStream(ch.cyberduck.core.io.VoidStatusOutputStream) MemorySegementingOutputStream(ch.cyberduck.core.io.MemorySegementingOutputStream) GraphExceptionMappingService(ch.cyberduck.core.onedrive.GraphExceptionMappingService) IOException(java.io.IOException) DefaultIOExceptionMappingService(ch.cyberduck.core.DefaultIOExceptionMappingService) UploadSession(org.nuxeo.onedrive.client.UploadSession) HostPreferences(ch.cyberduck.core.preferences.HostPreferences)

Example 5 with MemorySegementingOutputStream

use of ch.cyberduck.core.io.MemorySegementingOutputStream in project cyberduck by iterate-ch.

the class S3MultipartWriteFeature method write.

@Override
public HttpResponseOutputStream<StorageObject> write(final Path file, final TransferStatus status, final ConnectionCallback callback) throws BackgroundException {
    final S3Object object = new S3WriteFeature(session).getDetails(file, status);
    // ID for the initiated multipart upload.
    final MultipartUpload multipart;
    try {
        final Path bucket = containerService.getContainer(file);
        multipart = session.getClient().multipartStartUpload(bucket.isRoot() ? StringUtils.EMPTY : bucket.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<StorageObject>(new MemorySegementingOutputStream(proxy, new HostPreferences(session.getHost()).getInteger("s3.upload.multipart.size")), new S3AttributesAdapter(), status) {

        @Override
        public StorageObject getStatus() {
            if (proxy.getResponse() != null) {
                if (log.isDebugEnabled()) {
                    log.debug(String.format("Received response %s", proxy.getResponse()));
                }
                object.setETag(proxy.getResponse().getEtag());
                if (proxy.getResponse().getVersionId() != null) {
                    object.addMetadata(S3Object.S3_VERSION_ID, proxy.getResponse().getVersionId());
                }
            }
            return object;
        }
    };
}
Also used : Path(ch.cyberduck.core.Path) ServiceException(org.jets3t.service.ServiceException) MemorySegementingOutputStream(ch.cyberduck.core.io.MemorySegementingOutputStream) S3Object(org.jets3t.service.model.S3Object) HttpResponseOutputStream(ch.cyberduck.core.http.HttpResponseOutputStream) MultipartUpload(org.jets3t.service.model.MultipartUpload) HostPreferences(ch.cyberduck.core.preferences.HostPreferences)

Aggregations

MemorySegementingOutputStream (ch.cyberduck.core.io.MemorySegementingOutputStream)8 HttpResponseOutputStream (ch.cyberduck.core.http.HttpResponseOutputStream)7 HostPreferences (ch.cyberduck.core.preferences.HostPreferences)6 DisabledListProgressListener (ch.cyberduck.core.DisabledListProgressListener)2 CreateFileUploadResponse (ch.cyberduck.core.sds.io.swagger.client.model.CreateFileUploadResponse)2 IOException (java.io.IOException)2 DefaultIOExceptionMappingService (ch.cyberduck.core.DefaultIOExceptionMappingService)1 Path (ch.cyberduck.core.Path)1 UploadSession (ch.cyberduck.core.box.io.swagger.client.model.UploadSession)1 ResourceCreationResponseEntry (ch.cyberduck.core.eue.io.swagger.client.model.ResourceCreationResponseEntry)1 BackgroundException (ch.cyberduck.core.exception.BackgroundException)1 ChecksumException (ch.cyberduck.core.exception.ChecksumException)1 ConflictException (ch.cyberduck.core.exception.ConflictException)1 InteroperabilityException (ch.cyberduck.core.exception.InteroperabilityException)1 UnsupportedException (ch.cyberduck.core.exception.UnsupportedException)1 VoidStatusOutputStream (ch.cyberduck.core.io.VoidStatusOutputStream)1 GraphExceptionMappingService (ch.cyberduck.core.onedrive.GraphExceptionMappingService)1 ApiException (ch.cyberduck.core.sds.io.swagger.client.ApiException)1 NodesApi (ch.cyberduck.core.sds.io.swagger.client.api.NodesApi)1 CreateFileUploadRequest (ch.cyberduck.core.sds.io.swagger.client.model.CreateFileUploadRequest)1