feat: add onedrive file picker

This commit is contained in:
Gunwoo Hur
2025-02-24 17:27:37 +09:00
parent 737b1723c7
commit 0335d479f9
6 changed files with 328 additions and 0 deletions
@@ -2,6 +2,7 @@
import { toast } from 'svelte-sonner';
import { v4 as uuidv4 } from 'uuid';
import { createPicker, getAuthToken } from '$lib/utils/google-drive-picker';
import { openOneDrivePicker } from '$lib/utils/onedrive-file-picker';
import { onMount, tick, getContext, createEventDispatcher, onDestroy } from 'svelte';
const dispatch = createEventDispatcher();
@@ -1108,6 +1109,26 @@
);
}
}}
uploadOneDriveHandler={async () => {
try {
const fileData = await openOneDrivePicker();
if (fileData) {
const file = new File([fileData.blob], fileData.name, {
type: fileData.blob.type
});
await uploadFileHandler(file);
} else {
console.log('No file was selected from OneDrive');
}
} catch (error) {
console.error('OneDrive Error:', error);
toast.error(
$i18n.t('Error accessing OneDrive: {{error}}', {
error: error.message
})
);
}
}}
onClose={async () => {
await tick();