feat(files): upload files with drag and drop
This commit is contained in:
@@ -25,4 +25,9 @@ describe('FilesystemError', () => {
|
||||
expect(parseFilesystemErrorReason('made-up')).toBe('unknown');
|
||||
expect(parseFilesystemErrorReason(undefined)).toBe('unknown');
|
||||
});
|
||||
|
||||
test('recognizes filesystem errors created across runtime boundaries', () => {
|
||||
expect(isFilesystemError({ reason: 'already-exists' })).toBe(true);
|
||||
expect(isFilesystemError({ reason: 409 })).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export type FilesystemErrorReason =
|
||||
| 'os-permission'
|
||||
| 'already-exists'
|
||||
| 'not-found'
|
||||
| 'not-directory'
|
||||
| 'invalid-response'
|
||||
@@ -30,6 +31,7 @@ export const isFilesystemError = (error: unknown): error is FilesystemError => (
|
||||
export const parseFilesystemErrorReason = (value: unknown): FilesystemErrorReason => {
|
||||
switch (value) {
|
||||
case 'os-permission':
|
||||
case 'already-exists':
|
||||
case 'not-found':
|
||||
case 'not-directory':
|
||||
case 'invalid-response':
|
||||
|
||||
@@ -606,6 +606,7 @@ export interface FilesAPI {
|
||||
readFile?(path: string, options?: FileReadOptions): Promise<{ content: string; path: string }>;
|
||||
readFileBinary?(path: string, options?: FileReadOptions): Promise<{ dataUrl: string; path: string }>;
|
||||
writeFile?(path: string, content: string): Promise<{ success: boolean; path: string }>;
|
||||
uploadFile?(path: string, file: Blob, options?: { overwrite?: boolean; directory?: string }): Promise<{ success: boolean; path: string }>;
|
||||
delete?(path: string): Promise<{ success: boolean }>;
|
||||
rename?(oldPath: string, newPath: string): Promise<{ success: boolean; path: string }>;
|
||||
revealPath?(path: string): Promise<{ success: boolean }>;
|
||||
|
||||
Reference in New Issue
Block a user