address review comments

This commit is contained in:
Rushikesh Tote 2022-03-22 11:38:15 +05:30
parent afc7057e30
commit 42bfc71de6
8 changed files with 13 additions and 14 deletions

View file

@ -150,7 +150,7 @@ export default function Upload(props: Props) {
const uploadFailedFiles = async () => {
try {
const { files, collectionName, collectionIDs } =
await ImportService.getToUploadFiles();
await ImportService.getPendingUploads();
toUploadFiles = files;

View file

@ -42,10 +42,10 @@ class ImportService {
}
}
async getToUploadFiles() {
async getPendingUploads() {
if (this.allElectronAPIsExist) {
const { filesPaths, collectionName, collectionIDs } =
this.ElectronAPIs.getToUploadFiles();
this.ElectronAPIs.pendingToUploadFilePaths();
const files = await getElectronFiles(filesPaths);
return {
files,

View file

@ -49,7 +49,7 @@ export async function getElectronFileStream(
) {
const chunkCount = Math.ceil(file.size / chunkSize);
return {
stream: await file.createReadStream(),
stream: await file.stream(),
chunkCount,
};
}

View file

@ -82,12 +82,12 @@ export async function readLivePhoto(
const image =
livePhotoAssets.image instanceof File
? await getUint8ArrayView(reader, livePhotoAssets.image)
: await livePhotoAssets.image.toUInt8Array();
: await livePhotoAssets.image.arrayBuffer();
const video =
livePhotoAssets.video instanceof File
? await getUint8ArrayView(reader, livePhotoAssets.video)
: await livePhotoAssets.video.toUInt8Array();
: await livePhotoAssets.video.arrayBuffer();
return {
filedata: await encodeMotionPhoto({

View file

@ -34,7 +34,7 @@ export async function extractMetadata(
if (fileTypeInfo.fileType === FILE_TYPE.IMAGE) {
if (!(receivedFile instanceof File)) {
receivedFile = new File(
[await receivedFile.toBlob()],
[await receivedFile.blob()],
receivedFile.name,
{
lastModified: receivedFile.lastModified,
@ -81,7 +81,7 @@ export async function parseMetadataJSON(
try {
if (!(receivedFile instanceof File)) {
receivedFile = new File(
[await receivedFile.toBlob()],
[await receivedFile.blob()],
receivedFile.name
);
}

View file

@ -34,7 +34,7 @@ export async function generateThumbnail(
let canvas = document.createElement('canvas');
let thumbnail: Uint8Array;
if (!(file instanceof File)) {
file = new File([await file.toBlob()], file.name);
file = new File([await file.blob()], file.name);
}
try {
if (fileTypeInfo.fileType === FILE_TYPE.IMAGE) {

View file

@ -6,9 +6,8 @@ import { logError } from 'utils/sentry';
export async function getVideoMetadata(file: File | ElectronFile) {
let videoMetadata = NULL_EXTRACTED_METADATA;
if (!(file instanceof File)) {
file = new File([await file.toBlob()], file.name, {
file = new File([await file.blob()], file.name, {
lastModified: file.lastModified,
type: file.type.mimeType,
});
}
try {

View file

@ -76,9 +76,9 @@ export interface ElectronFile {
mimeType: string;
ext: string;
};
createReadStream: () => Promise<ReadableStream<Uint8Array>>;
toBlob: () => Promise<Blob>;
toUInt8Array: () => Promise<Uint8Array>;
stream: () => Promise<ReadableStream<Uint8Array>>;
blob: () => Promise<Blob>;
arrayBuffer: () => Promise<Uint8Array>;
}
export interface UploadAsset {