@leancodepl/api-binary-blob 9.6.5 → 9.6.6
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/README.md +18 -18
- package/index.cjs.js +4 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -41,12 +41,12 @@ Converts ApiBinary to Blob with optional content type.
|
|
|
41
41
|
import { fromBlob, toBlob } from "@leancodepl/api-binary-blob"
|
|
42
42
|
|
|
43
43
|
const handleFileUpload = async (file: File) => {
|
|
44
|
-
|
|
44
|
+
const binary = await fromBlob(file)
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
46
|
+
await api.post("/upload", {
|
|
47
|
+
fileName: file.name,
|
|
48
|
+
content: binary,
|
|
49
|
+
})
|
|
50
50
|
}
|
|
51
51
|
```
|
|
52
52
|
|
|
@@ -56,15 +56,15 @@ const handleFileUpload = async (file: File) => {
|
|
|
56
56
|
import { toBlob } from "@leancodepl/api-binary-blob"
|
|
57
57
|
|
|
58
58
|
const downloadFile = async (binary: ApiBinary, filename: string) => {
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
const blob = toBlob(binary, "application/octet-stream")
|
|
60
|
+
const url = URL.createObjectURL(blob)
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
62
|
+
const link = document.createElement("a")
|
|
63
|
+
link.href = url
|
|
64
|
+
link.download = filename
|
|
65
|
+
link.click()
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
URL.revokeObjectURL(url)
|
|
68
68
|
}
|
|
69
69
|
```
|
|
70
70
|
|
|
@@ -74,13 +74,13 @@ const downloadFile = async (binary: ApiBinary, filename: string) => {
|
|
|
74
74
|
import { fromBlob, toBlob } from "@leancodepl/api-binary-blob"
|
|
75
75
|
|
|
76
76
|
const processImage = async (imageFile: File) => {
|
|
77
|
-
|
|
77
|
+
const binary = await fromBlob(imageFile)
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
const processedBlob = toBlob(binary, "image/jpeg")
|
|
80
|
+
const preview = URL.createObjectURL(processedBlob)
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
const img = document.createElement("img")
|
|
83
|
+
img.src = preview
|
|
84
|
+
document.body.appendChild(img)
|
|
85
85
|
}
|
|
86
86
|
```
|
package/index.cjs.js
CHANGED
|
@@ -51,8 +51,8 @@ function toBlob(apiBinary$1, contentType) {
|
|
|
51
51
|
exports.fromBlob = fromBlob;
|
|
52
52
|
exports.toBlob = toBlob;
|
|
53
53
|
Object.keys(apiBinary).forEach(function (k) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () { return apiBinary[k]; }
|
|
57
|
+
});
|
|
58
58
|
});
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leancodepl/api-binary-blob",
|
|
3
|
-
"version": "9.6.
|
|
3
|
+
"version": "9.6.6",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@leancodepl/api-binary": "9.6.
|
|
6
|
+
"@leancodepl/api-binary": "9.6.6"
|
|
7
7
|
},
|
|
8
8
|
"devDependencies": {
|
|
9
9
|
"blob-polyfill": "^9.0.0"
|