@axium/storage 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.d.ts +5 -1
- package/dist/client.js +7 -2
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { StorageItemMetadata, StorageItemUpdate, UserFilesInfo } from './common.js';
|
|
2
2
|
import type { ItemSelection } from './selection.js';
|
|
3
3
|
export declare function parseItem(result: StorageItemMetadata): StorageItemMetadata;
|
|
4
|
-
export
|
|
4
|
+
export interface UploadOptions {
|
|
5
|
+
parentId?: string;
|
|
6
|
+
name?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function uploadItem(file: Blob | File, opt: UploadOptions): Promise<StorageItemMetadata>;
|
|
5
9
|
export declare function updateItem(fileId: string, data: Blob): Promise<StorageItemMetadata>;
|
|
6
10
|
export declare function getItemMetadata(fileId: string): Promise<StorageItemMetadata>;
|
|
7
11
|
export declare function getDirectoryMetadata(parentId: string): Promise<StorageItemMetadata[]>;
|
package/dist/client.js
CHANGED
|
@@ -30,8 +30,13 @@ export function parseItem(result) {
|
|
|
30
30
|
result.trashedAt = new Date(result.trashedAt);
|
|
31
31
|
return result;
|
|
32
32
|
}
|
|
33
|
-
export async function uploadItem(file,
|
|
34
|
-
|
|
33
|
+
export async function uploadItem(file, opt) {
|
|
34
|
+
const headers = {};
|
|
35
|
+
if (opt.parentId)
|
|
36
|
+
headers['x-parent'] = opt.parentId;
|
|
37
|
+
if (opt.name)
|
|
38
|
+
headers['x-name'] = opt.name;
|
|
39
|
+
return parseItem(await _upload('PUT', '/raw/storage', file, headers));
|
|
35
40
|
}
|
|
36
41
|
export async function updateItem(fileId, data) {
|
|
37
42
|
return parseItem(await _upload('POST', '/raw/storage/' + fileId, data));
|