address review comments
This commit is contained in:
parent
afc7057e30
commit
42bfc71de6
|
@ -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;
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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({
|
||||
|
|
|
@ -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
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue