public class UploadReader extends Object
moveBlocks(byte[], java.util.List<io.milton.zsync.RelocateRange>, int, byte[]) method copies ranges from the previous file according to
a list of RelocateRanges, while the sendRanges(byte[], java.util.List<io.milton.http.Range>, byte[]) method copies the new
data received in the upload. Both of these methods are overloaded with
versions that accept File rather than byte[] arguments for dealing with large
files that should not be loaded into memory all at once.
To assemble the file from a ZSync upload, the server should construct an
UploadReader, passing to the constructor the file to be updated and an
InputStream containing the upload data. It should then invoke the
assemble() method, which will return a temporary file that was
created.| Constructor and Description |
|---|
UploadReader(File serverFile,
InputStream uploadIn)
Constructor that parses the InputStream into an Upload object and
initializes a temporary file that will contain the assembled upload
|
| Modifier and Type | Method and Description |
|---|---|
File |
assemble()
Invokes the methods to put together the uploaded file.
|
String |
getChecksum()
Returns the expected SHA1 checksum String received in the upload
|
static void |
moveBlocks(byte[] in,
List<RelocateRange> rlist,
int blockSize,
byte[] out)
Copies blocks of data from the in array to the out array.
|
static void |
moveBlocks(File inFile,
Enumeration<RelocateRange> relocRanges,
int blocksize,
File outFile)
Copies blocks of data from the input File to the output File.
|
static void |
sendRanges(byte[] in,
List<Range> ranges,
byte[] out)
Copies bytes from the in array into Ranges of the out array.
|
static void |
sendRanges(Enumeration<ByteRange> byteRanges,
File outFile)
Inserts the data from each DataRange into the output File, at the
appropriate offset
|
public UploadReader(File serverFile, InputStream uploadIn) throws IOException
serverFile - The server file to be updateduploadIn - A stream containing the ZSync PUT dataIOExceptionpublic static void moveBlocks(byte[] in,
List<RelocateRange> rlist,
int blockSize,
byte[] out)
in - The byte array containing the server's file being replacedrlist - The List of RelocateRanges received from the uploadblockSize - The block size used in rlistout - The byte array of the file being assembledpublic static void moveBlocks(File inFile, Enumeration<RelocateRange> relocRanges, int blocksize, File outFile) throws IOException
inFile - The server's File being replacedrelocRanges - The Enumeration of RelocateRanges parsed from the
Upload's relocStreamblocksize - The block size used in relocRangesoutFile - The File being assembledIOExceptionpublic static void sendRanges(byte[] in,
List<Range> ranges,
byte[] out)
in - An array containing the queued bytes corresponding to the
ranges Listranges - The List of target Rangesout - The byte array for the file being assembledpublic static void sendRanges(Enumeration<ByteRange> byteRanges, File outFile) throws IOException
byteRanges - The Enumeration of Range/InputStream pairs parsed from
the Upload's dataStreamoutFile - The output File being assembledIOExceptionpublic File assemble() throws IOException
IOExceptionpublic String getChecksum()
Copyright © 2021 McEvoy Software Ltd. All rights reserved.