All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nl.tweeenveertig.openstack.instructions.UploadPayloadByteArray Maven / Gradle / Ivy

There is a newer version: 0.7.0
Show newest version
package nl.tweeenveertig.openstack.instructions;

import nl.tweeenveertig.openstack.headers.object.Etag;
import org.apache.http.HttpEntity;
import org.apache.http.entity.ByteArrayEntity;

import java.io.IOException;

public class UploadPayloadByteArray extends UploadPayload {

    private byte[] bytes;

    public UploadPayloadByteArray(final byte[] bytes) {
        this.bytes = bytes;
    }

    @Override
    public HttpEntity getEntity() {
        return new ByteArrayEntity(this.bytes);
    }

    @Override
    public boolean mustBeSegmented(Long segmentationSize) {
        return this.bytes.length > segmentationSize;
    }

    @Override
    public Etag getEtag() throws IOException {
        return new Etag(getEntity().getContent());
    }

    @Override
    public SegmentationPlan getSegmentationPlan(Long segmentationSize) throws IOException {
        return new SegmentationPlanByteArray(this.bytes, segmentationSize);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy