Esempio n. 1
0
 /**
  * 创建块,并上传第一个分片内容
  *
  * @param address 上传主机
  * @param offset 本地文件偏移量
  * @param blockSize 分块的块大小
  * @param chunkSize 分片的片大小
  * @param progress 上传进度
  * @param _completionHandler 上传完成处理动作
  */
 private void makeBlock(
     URI address,
     int offset,
     int blockSize,
     int chunkSize,
     ProgressHandler progress,
     CompletionHandler _completionHandler,
     UpCancellationSignal c) {
   String path = format(Locale.ENGLISH, "/mkblk/%d", blockSize);
   try {
     file.seek(offset);
     file.read(chunkBuffer, 0, chunkSize);
   } catch (IOException e) {
     completionHandler.complete(key, ResponseInfo.fileError(e), null);
     return;
   }
   this.crc32 = Crc32.bytes(chunkBuffer, 0, chunkSize);
   URI u = newURI(address, path);
   post(u, chunkBuffer, 0, chunkSize, progress, _completionHandler, c);
 }
Esempio n. 2
0
 private void putChunk(
     URI address,
     int offset,
     int chunkSize,
     String context,
     ProgressHandler progress,
     CompletionHandler _completionHandler,
     UpCancellationSignal c) {
   int chunkOffset = offset % Configuration.BLOCK_SIZE;
   String path = format(Locale.ENGLISH, "/bput/%s/%d", context, chunkOffset);
   try {
     file.seek(offset);
     file.read(chunkBuffer, 0, chunkSize);
   } catch (IOException e) {
     completionHandler.complete(key, ResponseInfo.fileError(e), null);
     return;
   }
   this.crc32 = Crc32.bytes(chunkBuffer, 0, chunkSize);
   URI u = newURI(address, path);
   post(u, chunkBuffer, 0, chunkSize, progress, _completionHandler, c);
 }