[#29] Provide a FileInputStream for the putObject method
Signed-off-by: Ori Bruk <o.bruk@yadro.com>
This commit is contained in:
parent
aa3cff5a03
commit
24151784fe
2 changed files with 9 additions and 9 deletions
|
@ -6,7 +6,7 @@ import info.frostfs.sdk.dto.session.SessionToken;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import java.io.InputStream;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
|
@ -16,7 +16,7 @@ public class PutObjectParameters {
|
||||||
private ObjectHeader header;
|
private ObjectHeader header;
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private FileInputStream payload;
|
private InputStream payload;
|
||||||
|
|
||||||
private boolean clientCut;
|
private boolean clientCut;
|
||||||
private int bufferMaxSize;
|
private int bufferMaxSize;
|
||||||
|
@ -26,14 +26,14 @@ public class PutObjectParameters {
|
||||||
private long currentStreamPosition;
|
private long currentStreamPosition;
|
||||||
private long fullLength;
|
private long fullLength;
|
||||||
|
|
||||||
public PutObjectParameters(ObjectHeader header, FileInputStream payload, boolean clientCut, int bufferMaxSize) {
|
public PutObjectParameters(ObjectHeader header, InputStream payload, boolean clientCut, int bufferMaxSize) {
|
||||||
this.header = header;
|
this.header = header;
|
||||||
this.payload = payload;
|
this.payload = payload;
|
||||||
this.clientCut = clientCut;
|
this.clientCut = clientCut;
|
||||||
this.bufferMaxSize = bufferMaxSize;
|
this.bufferMaxSize = bufferMaxSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PutObjectParameters(ObjectHeader header, FileInputStream payload) {
|
public PutObjectParameters(ObjectHeader header, InputStream payload) {
|
||||||
this.header = header;
|
this.header = header;
|
||||||
this.payload = payload;
|
this.payload = payload;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,8 @@ import info.frostfs.sdk.tools.Verifier;
|
||||||
import info.frostfs.sdk.utils.Validator;
|
import info.frostfs.sdk.utils.Validator;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -329,17 +329,17 @@ public class ObjectClientImpl extends ContextAccessor implements ObjectClient {
|
||||||
return new SearchReader(objectServiceBlockingClient.search(initRequest));
|
return new SearchReader(objectServiceBlockingClient.search(initRequest));
|
||||||
}
|
}
|
||||||
|
|
||||||
private int readNBytes(FileInputStream fileInputStream, byte[] buffer, int size) {
|
private int readNBytes(InputStream inputStream, byte[] buffer, int size) {
|
||||||
try {
|
try {
|
||||||
return fileInputStream.readNBytes(buffer, 0, size);
|
return inputStream.readNBytes(buffer, 0, size);
|
||||||
} catch (IOException exp) {
|
} catch (IOException exp) {
|
||||||
throw new ProcessFrostFSException(exp.getMessage());
|
throw new ProcessFrostFSException(exp.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private long getStreamSize(FileInputStream fileInputStream) {
|
private long getStreamSize(InputStream inputStream) {
|
||||||
try {
|
try {
|
||||||
return fileInputStream.getChannel().size();
|
return inputStream.available();
|
||||||
} catch (IOException exp) {
|
} catch (IOException exp) {
|
||||||
throw new ProcessFrostFSException(exp.getMessage());
|
throw new ProcessFrostFSException(exp.getMessage());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue