diff --git a/src/lib/components/NavBar.svelte b/src/lib/components/NavBar.svelte
index c6a7262..e38f636 100644
--- a/src/lib/components/NavBar.svelte
+++ b/src/lib/components/NavBar.svelte
@@ -37,7 +37,7 @@
(uploadModalOpen = true)} />
- goto('/cloud')} />
+
diff --git a/src/lib/util/cloud.ts b/src/lib/util/cloud.ts
new file mode 100644
index 0000000..4e95108
--- /dev/null
+++ b/src/lib/util/cloud.ts
@@ -0,0 +1,32 @@
+type FileInfo = {
+ accessToken: string;
+ metadata: any;
+ fileId?: string;
+ localStorageId: string;
+ type: string;
+}
+
+const FILES_API_URL = 'https://www.googleapis.com/upload/drive/v3/files';
+
+export async function uploadFile({ accessToken, fileId, localStorageId, metadata, type }: FileInfo) {
+ const json = localStorage.getItem(localStorageId) || '';
+ const blob = new Blob([json], { type });
+
+ const form = new FormData();
+
+ form.append('resource', new Blob([JSON.stringify(metadata)], { type }));
+ form.append('file', blob);
+
+
+ const res = await fetch(
+ `${FILES_API_URL}${fileId ? `/${fileId}` : ''}?uploadType=multipart`,
+ {
+ method: fileId ? 'PATCH' : 'POST',
+ headers: new Headers({ Authorization: 'Bearer ' + accessToken }),
+ body: form
+ }
+ );
+
+ return await res.json()
+}
+
diff --git a/src/lib/util/index.ts b/src/lib/util/index.ts
index 768a78e..629bdc9 100644
--- a/src/lib/util/index.ts
+++ b/src/lib/util/index.ts
@@ -2,4 +2,5 @@ export * from './snackbar';
export * from './upload';
export * from './misc';
export * from './modals';
-export * from './zip'
\ No newline at end of file
+export * from './zip'
+export * from './cloud'
\ No newline at end of file
diff --git a/src/routes/cloud/+page.svelte b/src/routes/cloud/+page.svelte
index 2999d78..c6227c4 100644
--- a/src/routes/cloud/+page.svelte
+++ b/src/routes/cloud/+page.svelte
@@ -1,29 +1,32 @@
@@ -209,49 +254,66 @@
{loadingMessage}
{:else if zips}
-
-
-
Google Drive:
-
- {#if zips.length > 0}
-
- {#each zips as zip}
- onClick(zip)}
- rounded
- border
- class="divide-y divide-gray-200 dark:divide-gray-600"
- >
-
-
-
{zip.name}
-
{formatBytes(parseInt(zip.size || '0'))}
-
-
-
- {/each}
-
- {:else}
-
- Add your zip files to the {READER_FOLDER} folder
- in your Google Drive.
-
+
+
+
Google Drive:
+
+
+ {#if volumeDataId}
+
+ {/if}
+
+ {#if profilesId}
+
{/if}
-
-
- {#if volumeDataId}
-
+
+ {#if zips.length > 0}
+
+ {#each zips as zip}
+ onClick(zip)}
+ rounded
+ border
+ class="divide-y divide-gray-200 dark:divide-gray-600"
+ >
+
+
+
{zip.name}
+
{formatBytes(parseInt(zip.size || '0'))}
+
+
+
+ {/each}
+
+ {:else}
+
+ Add your zip files to the {READER_FOLDER} folder in
+ your Google Drive.
+
{/if}