public class UploadHelper
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_BUFFSIZE |
Constructor and Description |
---|
UploadHelper(EsuApi api)
Creates a new upload helper using a default 4MB buffer.
|
UploadHelper(EsuApi esu,
byte[] buffer)
Creates a new upload helper.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(ProgressListener l)
Adds the given progress listener to the listener list.
|
ObjectId |
createObject(java.io.File f,
Acl acl,
MetadataList meta)
Creates a new object on the server with the contents of the given file,
acl and metadata.
|
ObjectId |
createObject(java.io.InputStream stream,
Acl acl,
MetadataList metadata,
boolean closeStream)
Creates a new object on the server with the contents of the given stream,
acl and metadata.
|
ObjectId |
createObjectOnPath(ObjectPath path,
java.io.File f,
Acl acl,
MetadataList meta)
Creates an object on the server on the given path, file, acl, and metadata.
|
ObjectId |
createObjectOnPath(ObjectPath path,
java.io.InputStream stream,
Acl acl,
MetadataList metadata,
boolean closeStream)
Creates a new object on the server with the contents of the given stream,
acl and metadata located at the given path.
|
long |
getCurrentBytes()
Returns the current number of bytes uploaded.
|
java.lang.Exception |
getError()
Returns the Exception that caused the upload to fail.
|
java.lang.String |
getMimeType() |
int |
getMinReadSize() |
long |
getTotalBytes()
Returns the total bytes in the request.
|
boolean |
isChecksumming() |
boolean |
isComplete()
Returns true if the upload request has completed.
|
boolean |
isFailed()
Returns true if the upload request has failed.
|
void |
removeListener(ProgressListener l)
Removes the given progress listener from the listener list.
|
void |
setChecksumming(boolean checksumming) |
void |
setMimeType(java.lang.String mimeType)
Sets the mimetype to be used when creating the object.
|
void |
setMinReadSize(int minReadSize) |
void |
setTotalBytes(long totalBytes)
Sets the total number of bytes to transfer in the upload
|
void |
updateObject(Identifier id,
java.io.File f,
Acl acl,
MetadataList metadata)
Updates an existing object with the contents of the given file, ACL, and
metadata.
|
void |
updateObject(Identifier id,
java.io.InputStream stream,
Acl acl,
MetadataList metadata,
boolean closeStream)
Updates an existing object with the contents of the given stream, ACL, and
metadata.
|
public static final int DEFAULT_BUFFSIZE
public UploadHelper(EsuApi esu, byte[] buffer)
esu
- the API connection object to use to communicate
with the serverbuffer
- the buffer used for making the transfers. If null, a
4MB buffer will be allocated.public UploadHelper(EsuApi api)
api
- the API connection object to use to communicate
with the serverpublic ObjectId createObject(java.io.File f, Acl acl, MetadataList meta)
f
- the path to the file to uploadacl
- the ACL to assign to the new object. Optional. If null,
the server will generate a default ACL for the file.meta
- The metadata to assign to the new object.
Optional. If null, no user metadata will be assigned to the new object.public ObjectId createObject(java.io.InputStream stream, Acl acl, MetadataList metadata, boolean closeStream)
stream
- the stream to upload. The stream will be read until
an EOF is encountered.acl
- the ACL to assign to the new object. Optional. If null,
the server will generate a default ACL for the file.metadata
- The metadata to assign to the new object.
Optional. If null, no user metadata will be assigned to the new object.closeStream
- if true, the stream will be closed after
the transfer completes. If false, the stream will not be closed.public ObjectId createObjectOnPath(ObjectPath path, java.io.File f, Acl acl, MetadataList meta)
path
- the path to create the file onf
- the path to the file to uploadacl
- the ACL to assign to the new object. Optional. If null,
the server will generate a default ACL for the file.meta
- The metadata to assign to the new object.
Optional. If null, no user metadata will be assigned to the new object.public ObjectId createObjectOnPath(ObjectPath path, java.io.InputStream stream, Acl acl, MetadataList metadata, boolean closeStream)
path
- the object path for the new object.stream
- the stream to upload. The stream will be read until
an EOF is encountered.acl
- the ACL to assign to the new object. Optional. If null,
the server will generate a default ACL for the file.metadata
- The metadata to assign to the new object.
Optional. If null, no user metadata will be assigned to the new object.closeStream
- if true, the stream will be closed after
the transfer completes. If false, the stream will not be closed.public void updateObject(Identifier id, java.io.File f, Acl acl, MetadataList metadata)
id
- the identifier of the object to update.f
- the path to the file to replace the object's current
contents withacl
- the ACL to update the object with. Optional. If null,
the ACL will not be modified.metadata
- The metadata to assign to the object.
Optional. If null, no user metadata will be modified.public void updateObject(Identifier id, java.io.InputStream stream, Acl acl, MetadataList metadata, boolean closeStream)
id
- the identifier of the object to update.stream
- the stream to replace the object's current
contents with. The stream will be read until an EOF is encountered.acl
- the ACL to update the object with. Optional. If not
specified, the ACL will not be modified.metadata
- The metadata to assign to the object.
Optional. If null, no user metadata will be modified.public void addListener(ProgressListener l)
l
- the listener to addpublic void removeListener(ProgressListener l)
l
- the listener to removepublic long getTotalBytes()
public void setTotalBytes(long totalBytes)
totalBytes
- the totalBytes to setpublic long getCurrentBytes()
public boolean isComplete()
public boolean isFailed()
public java.lang.Exception getError()
public void setMinReadSize(int minReadSize)
public int getMinReadSize()
public boolean isChecksumming()
public void setChecksumming(boolean checksumming)
checksumming
- the checksumming to setpublic void setMimeType(java.lang.String mimeType)
mimeType
- the mimeTypepublic java.lang.String getMimeType()