public class Upload extends Object
| Modifier and Type | Class and Description |
|---|---|
static class |
Upload.IteratorEnum<T>
An
Enumeration wrapper for an Iterator. |
static class |
Upload.KeyValue
An object representing a (Key, Value) pair of Strings.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
BLOCKSIZE |
static String |
CHARSET
The character encoding used to convert Strings to bytes.
|
String |
DIV
A String that marks the beginning of a range of uploaded bytes.
|
static String |
FILELENGTH |
static char |
LF
The character marking the end of a line.
|
static String |
NEWDATA
The total number of bytes of new data to be transmitted.
|
static String |
RANGE |
static String |
RELOCATE |
static String |
SHA_1 |
static String |
VERSION |
| Constructor and Description |
|---|
Upload()
Constructs an empty Upload object.
|
| Modifier and Type | Method and Description |
|---|---|
long |
getBlocksize()
Gets the blocksize used in the upload.
|
InputStream |
getDataStream()
Gets the list of uploaded data chunks ( byte Ranges and their associated data ).
|
long |
getFilelength()
Gets the length of the (assembled) source file being uploaded
|
InputStream |
getInputStream()
Returns an InputStream containing a complete ZSync upload (Params, Relocate stream, and ByteRange stream),
ready to be sent as the body of a PUT request.
|
String |
getParams()
Returns the list of headers in String format, in the proper format for upload.
|
InputStream |
getRelocStream()
Gets the list of RelocateRanges, which tells the server which blocks of the previous
file to keep, and where to place them in the new file.
|
String |
getSha1()
Gets the checksum for the entire source file
|
String |
getVersion()
Gets the zsync version of the upload sender (client)
|
static String |
paramString(String key,
Object value) |
static Upload |
parse(InputStream in)
Parses the InputStream into an Upload object.
|
static String |
readToken(InputStream in,
byte[] delimiters,
int maxsearch)
Returns the next String terminated by one of the specified delimiters or the end of the InputStream.
|
static String |
readValue(InputStream in,
int maxsearch)
Helper method that reads the String preceding the first newline in the InputStream.
|
void |
setBlocksize(long blocksize)
Sets the blocksize used in the upload.
|
void |
setDataStream(InputStream dataStream)
Sets the list of data chunks to be uploaded ( byte Ranges and their associated data ).
|
void |
setFilelength(long filelength)
Sets the length of the (assembled) source file being uploaded
|
void |
setRelocStream(InputStream relocStream)
Sets the list of RelocateRanges, which tells the server which blocks of the previous
file to keep, and where to place them in the new file.
|
void |
setSha1(String sha1)
Sets the checksum for the entire source file, which allow the server to validate the new file
after assembling it.
|
void |
setVersion(String version)
Sets the zsync version of the upload sender (client)
|
public static final String CHARSET
public static final char LF
public String DIV
public static final String VERSION
public static final String BLOCKSIZE
public static final String FILELENGTH
public static final String NEWDATA
public static final String SHA_1
public static final String RELOCATE
public static final String RANGE
public Upload()
public String getParams()
public static Upload parse(InputStream in)
parseParam(java.lang.String, java.lang.String) on each key value pair.
If the key is RELOCATE, then the value is not read, but is copied into a BufferingOutputStream and stored in the relocStream field. Parsing of headers
continues until a "blank" line is reached, ie a line that is null or contains only whitespace, which indicates the beginning of the data section.
A reference to the remaining InputStream is then stored in the dataStream field.in - The InputStream containing the ZSync uploadpublic static String readToken(InputStream in, byte[] delimiters, int maxsearch) throws ParseException, IOException
in - The InputStream to read fromdelimiters - A list of byte values, each of which indicates the end of a tokenmaxsearch - The maximum number of bytes to search for a delimiterIOExceptionParseException - If a delimiter byte is not found within maxsearch readspublic static String readValue(InputStream in, int maxsearch) throws ParseException, IOException
in - The InputStream to read frommaxsearch - The maximum number of bytes allowed in the valueParseException - If a newline or end of input is not reached within maxsearch readsIOExceptionpublic InputStream getInputStream() throws UnsupportedEncodingException, IOException
UnsupportedEncodingExceptionIOExceptionpublic String getVersion()
public void setVersion(String version)
public String getSha1()
public void setSha1(String sha1)
public long getBlocksize()
public void setBlocksize(long blocksize)
public long getFilelength()
public void setFilelength(long filelength)
public InputStream getRelocStream()
public void setRelocStream(InputStream relocStream)
relocStream - public InputStream getDataStream()
public void setDataStream(InputStream dataStream)
Copyright © 2021 McEvoy Software Ltd. All rights reserved.