Update file upload API
This commit is contained in:
parent
c61368f7f2
commit
831de35e9c
2 changed files with 8 additions and 8 deletions
|
@ -70,13 +70,13 @@ class FileUploadManager {
|
|||
|
||||
final metadata = jsonEncode(file.getMetadata());
|
||||
final encryptedMetadata =
|
||||
CryptoUtil.encryptDataToData(utf8.encode(metadata), key);
|
||||
await CryptoUtil.encryptDataToData(utf8.encode(metadata), key);
|
||||
final data = {
|
||||
"fileObjectKey": fileObjectKey,
|
||||
"thumbnailObjectKey": thumbnailObjectKey,
|
||||
"metadata": encryptedMetadata,
|
||||
"encryptedKey": encryptedKey,
|
||||
"iv": iv,
|
||||
"encryptedKeyIV": iv,
|
||||
};
|
||||
return _dio
|
||||
.post(
|
||||
|
@ -93,7 +93,7 @@ class FileUploadManager {
|
|||
file.updationTime = data["updationTime"];
|
||||
file.ownerID = data["ownerID"];
|
||||
file.encryptedKey = encryptedKey;
|
||||
file.iv = iv;
|
||||
file.encryptedKeyIV = iv;
|
||||
return file;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -68,9 +68,9 @@ class CryptoUtil {
|
|||
Configuration.instance.getTempDirectory() + Uuid().v4();
|
||||
return encryptDataToFile(source, destinationPath, key).then((value) {
|
||||
final file = io.File(destinationPath);
|
||||
final data = file.readAsStringSync(encoding: utf8);
|
||||
final data = file.readAsBytesSync();
|
||||
file.deleteSync();
|
||||
return data;
|
||||
return base64.encode(data);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -90,13 +90,13 @@ class CryptoUtil {
|
|||
return Computer().compute(runDecryptFileToData, param: args);
|
||||
}
|
||||
|
||||
static Future<String> decryptDataToData(String source, String key) {
|
||||
static Future<Uint8List> decryptDataToData(String source, String key) {
|
||||
final sourcePath = Configuration.instance.getTempDirectory() + Uuid().v4();
|
||||
final file = io.File(sourcePath);
|
||||
file.writeAsStringSync(source);
|
||||
file.writeAsBytesSync(base64.decode(source));
|
||||
return decryptFileToData(sourcePath, key).then((value) {
|
||||
file.deleteSync();
|
||||
return utf8.decode(value);
|
||||
return value;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue