upload method

Future upload(
  1. String path,
  2. String savePath, {
  3. bool autoStartTask = true,
  4. dynamic shouldTruncate = true,
})

Implementation

Future upload(String path, String savePath,
    {bool autoStartTask = true, shouldTruncate = true}) async {
  var fileStat = await File(path).stat();
  var fileInfo = FileInfo(
    filePath: savePath,
    size: Int64(fileStat.size),
    modifyTime: Timestamp.fromDateTime(fileStat.modified),
    isDir: fileStat.type == FileSystemEntityType.directory,
    isCompressed: false,
  );

  dio.Options options = dio.Options(headers: {
    "Content-Length": fileInfo.size.toString(),
    "Is-Dir": fileInfo.isDir.toString(),
    "Should-Truncate": shouldTruncate.toString(),
  });

  var file = File(path);
  var fs = file.openRead();
  await _client.put('/file/' + Uri.encodeFull(savePath),
      data: fs, options: options);
}