@oino-ts/blob-azure 1.0.6 → 1.0.8
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.
|
@@ -38,6 +38,7 @@ const blob_1 = require("@oino-ts/blob");
|
|
|
38
38
|
* })
|
|
39
39
|
* ```
|
|
40
40
|
*/
|
|
41
|
+
const BLOB_AZURE_ILLEGAL_CHARS_REGEX = /[\x00-\x1f\x7f\\]/g;
|
|
41
42
|
class OINOBlobAzure extends blob_1.OINOBlob {
|
|
42
43
|
_containerClient = null;
|
|
43
44
|
constructor(params) {
|
|
@@ -46,6 +47,13 @@ class OINOBlobAzure extends blob_1.OINOBlob {
|
|
|
46
47
|
throw new Error("OINOBlobAzure: missing or invalid credentials (provide either connectionStr or url and clientId)");
|
|
47
48
|
}
|
|
48
49
|
}
|
|
50
|
+
/**
|
|
51
|
+
* Replace characters that Azure Blob Storage does not permit in blob names
|
|
52
|
+
* (`\` and ASCII control characters) with `_`.
|
|
53
|
+
*/
|
|
54
|
+
sanitizeName(name) {
|
|
55
|
+
return name.replace(BLOB_AZURE_ILLEGAL_CHARS_REGEX, "_");
|
|
56
|
+
}
|
|
49
57
|
/**
|
|
50
58
|
* Initialise the Azure SDK client. Does not perform any network call.
|
|
51
59
|
*/
|
|
@@ -35,6 +35,7 @@ import { OINOBlob, OINOBlobDataModel } from "@oino-ts/blob";
|
|
|
35
35
|
* })
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
|
+
const BLOB_AZURE_ILLEGAL_CHARS_REGEX = /[\x00-\x1f\x7f\\]/g;
|
|
38
39
|
export class OINOBlobAzure extends OINOBlob {
|
|
39
40
|
_containerClient = null;
|
|
40
41
|
constructor(params) {
|
|
@@ -43,6 +44,13 @@ export class OINOBlobAzure extends OINOBlob {
|
|
|
43
44
|
throw new Error("OINOBlobAzure: missing or invalid credentials (provide either connectionStr or url and clientId)");
|
|
44
45
|
}
|
|
45
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Replace characters that Azure Blob Storage does not permit in blob names
|
|
49
|
+
* (`\` and ASCII control characters) with `_`.
|
|
50
|
+
*/
|
|
51
|
+
sanitizeName(name) {
|
|
52
|
+
return name.replace(BLOB_AZURE_ILLEGAL_CHARS_REGEX, "_");
|
|
53
|
+
}
|
|
46
54
|
/**
|
|
47
55
|
* Initialise the Azure SDK client. Does not perform any network call.
|
|
48
56
|
*/
|
|
@@ -1,34 +1,13 @@
|
|
|
1
1
|
import { OINOApi, OINOResult, OINOQueryFilter } from "@oino-ts/common";
|
|
2
2
|
import { OINOBlob, OINOBlobParams, type OINOBlobEntry, type OINOBlobFetchResult } from "@oino-ts/blob";
|
|
3
|
-
/**
|
|
4
|
-
* Azure Blob Storage implementation of `OINOBlob`.
|
|
5
|
-
*
|
|
6
|
-
* Authenticates using an Azure Storage connection string. Connection parameters map as:
|
|
7
|
-
* - `params.url` → blob service endpoint, e.g. `https://<account>.blob.core.windows.net`
|
|
8
|
-
* - `params.container` → container name
|
|
9
|
-
* - `params.connectionStr` → Azure Storage connection string (e.g. `DefaultEndpointsProtocol=https;AccountName=...`)
|
|
10
|
-
*
|
|
11
|
-
* Register and use via the factory:
|
|
12
|
-
* ```ts
|
|
13
|
-
* import { OINOBlobFactory } from "@oino-ts/blob"
|
|
14
|
-
* import { OINOBlobAzure } from "@oino-ts/blob-azure"
|
|
15
|
-
*
|
|
16
|
-
* OINOBlobFactory.registerBlob("OINOBlobAzure", OINOBlobAzure)
|
|
17
|
-
*
|
|
18
|
-
* const blob = await OINOBlobFactory.createBlob({
|
|
19
|
-
* type: "OINOBlobAzure",
|
|
20
|
-
* container: "my-container",
|
|
21
|
-
* credentials: either connectionStr or url and clientId
|
|
22
|
-
* })
|
|
23
|
-
* const api = await OINOBlobFactory.createApi(blob, {
|
|
24
|
-
* apiName: "files",
|
|
25
|
-
* tableName: "uploads/" // blob prefix / folder
|
|
26
|
-
* })
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
3
|
export declare class OINOBlobAzure extends OINOBlob {
|
|
30
4
|
private _containerClient;
|
|
31
5
|
constructor(params: OINOBlobParams);
|
|
6
|
+
/**
|
|
7
|
+
* Replace characters that Azure Blob Storage does not permit in blob names
|
|
8
|
+
* (`\` and ASCII control characters) with `_`.
|
|
9
|
+
*/
|
|
10
|
+
sanitizeName(name: string): string;
|
|
32
11
|
/**
|
|
33
12
|
* Initialise the Azure SDK client. Does not perform any network call.
|
|
34
13
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oino-ts/blob-azure",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "OINO TS package for using Azure Blob Storage as a REST API.",
|
|
5
5
|
"author": "Matias Kiviniemi (pragmatta)",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@azure/storage-blob": "^12.0.0",
|
|
24
24
|
"@azure/identity": "^3.0.0",
|
|
25
|
-
"@oino-ts/blob": "1.0.
|
|
26
|
-
"@oino-ts/common": "1.0.
|
|
25
|
+
"@oino-ts/blob": "1.0.8",
|
|
26
|
+
"@oino-ts/common": "1.0.8"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@oino-ts/types": "1.0.
|
|
29
|
+
"@oino-ts/types": "1.0.8",
|
|
30
30
|
"@types/bun": "^1.1.14",
|
|
31
31
|
"@types/node": "^22.0.00",
|
|
32
32
|
"typescript": "~5.9.0"
|