@metarisc/metarisc-js 0.0.1-alpha.73 → 0.0.1-alpha.74
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/lib/tus.d.ts +4 -1
- package/lib/tus.js +14 -2
- package/package.json +2 -2
- package/src/tus.ts +18 -2
package/lib/tus.d.ts
CHANGED
|
@@ -3,5 +3,8 @@ import { Client } from './client';
|
|
|
3
3
|
export declare class Tus extends Core {
|
|
4
4
|
constructor(config: MetariscConfig, client: Client);
|
|
5
5
|
upload(file: File, errorFn: (error: Error) => void, chunckFn: (url: string, progress: number) => void, successFn: () => void): void;
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Récupération d'un fichier stocké sous forme de Blob.
|
|
8
|
+
*/
|
|
9
|
+
download(url: string): Promise<Blob>;
|
|
7
10
|
}
|
package/lib/tus.js
CHANGED
|
@@ -47,10 +47,22 @@ class Tus extends core_1.Core {
|
|
|
47
47
|
});
|
|
48
48
|
upload.start();
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
/**
|
|
51
|
+
* Récupération d'un fichier stocké sous forme de Blob.
|
|
52
|
+
*/
|
|
53
|
+
async download(url) {
|
|
51
54
|
return this.request({
|
|
52
55
|
method: "GET",
|
|
53
|
-
endpoint:
|
|
56
|
+
endpoint: url
|
|
57
|
+
}).then((response) => {
|
|
58
|
+
//Récupérer le type de fichier
|
|
59
|
+
const fileType = response.headers["content-type"] ||
|
|
60
|
+
"application/octet-stream";
|
|
61
|
+
// Créer un tableau de bytes à partir de la réponse
|
|
62
|
+
const encoder = new TextEncoder();
|
|
63
|
+
const byteArray = encoder.encode(response.data);
|
|
64
|
+
// Créer et retourner un Blob à partir du tableau de bytes
|
|
65
|
+
return new Blob([byteArray], { type: fileType });
|
|
54
66
|
});
|
|
55
67
|
}
|
|
56
68
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@metarisc/metarisc-js",
|
|
3
3
|
"main": "lib/index.js",
|
|
4
4
|
"types": "lib/index.d.ts",
|
|
5
|
-
"version": "0.0.1-alpha.
|
|
5
|
+
"version": "0.0.1-alpha.74",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"lint": "eslint . --ext .ts --fix",
|
|
8
8
|
"compile": "tsc",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"typescript": "^4.9.5"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"axios": "^1.
|
|
21
|
+
"axios": "^1.7.7",
|
|
22
22
|
"axios-cache-interceptor": "^1.3.2",
|
|
23
23
|
"axios-oauth-client": "^2.0.4",
|
|
24
24
|
"axios-retry": "^3.5.0",
|
package/src/tus.ts
CHANGED
|
@@ -55,10 +55,26 @@ export class Tus extends Core
|
|
|
55
55
|
upload.start();
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Récupération d'un fichier stocké sous forme de Blob.
|
|
60
|
+
*/
|
|
61
|
+
async download(url: string): Promise<Blob> {
|
|
59
62
|
return this.request({
|
|
60
63
|
method: "GET",
|
|
61
|
-
endpoint:
|
|
64
|
+
endpoint: url
|
|
65
|
+
}).then((response) => {
|
|
66
|
+
|
|
67
|
+
//Récupérer le type de fichier
|
|
68
|
+
const fileType =
|
|
69
|
+
(response.headers["content-type"] as string) ||
|
|
70
|
+
"application/octet-stream";
|
|
71
|
+
|
|
72
|
+
// Créer un tableau de bytes à partir de la réponse
|
|
73
|
+
const encoder = new TextEncoder();
|
|
74
|
+
const byteArray = encoder.encode(response.data as string);
|
|
75
|
+
|
|
76
|
+
// Créer et retourner un Blob à partir du tableau de bytes
|
|
77
|
+
return new Blob([byteArray], { type: fileType });
|
|
62
78
|
});
|
|
63
79
|
}
|
|
64
80
|
}
|