Skip to content

Commit 1f7b75d

Browse files
committed
Get & Delete Blob, Delete container
1 parent ce5c3ed commit 1f7b75d

File tree

5 files changed

+66
-6
lines changed

5 files changed

+66
-6
lines changed

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1+
![Banner image](https://user-images.githubusercontent.com/10284570/173569848-c624317f-42b1-45a6-ab09-f0ea3c247648.png)
2+
13
# n8n-nodes-azure-blob-storage
24

5+
![Build](https://github.com/pregress/n8n-nodes-azure-blob-storage/actions/workflows/build.yml/badge.svg)
6+
[![NPM version][npm-version-image]][npm-url]
7+
[![NPM downloads][npm-downloads-image]][npm-downloads-url]
8+
9+
[npm-url]: https://npmjs.org/package/n8n-nodes-azure-blob-storage
10+
[npm-version-image]: https://img.shields.io/npm/v/n8n-nodes-azure-blob-storage.svg?style=flat
11+
[npm-downloads-image]: https://img.shields.io/npm/dm/n8n-nodes-azure-blob-storage.svg?style=flat
12+
[npm-downloads-url]: https://npmcharts.com/compare/n8n-nodes-azure-blob-storage?minimal=true
13+
14+
315
This is an n8n community node. It lets you use Azure blob storage in your n8n workflows.
416

517
Azure Blob Storage is Microsoft's object storage solution for the cloud. Blob storage is optimized for storing massive amounts of unstructured data.
@@ -23,9 +35,12 @@ Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes
2335
- Containers
2436
- List
2537
- Create
38+
- Delete
2639
- Blobs
2740
- List
2841
- Upload
42+
- Get
43+
- Delete
2944

3045

3146
More to come.
@@ -45,6 +60,21 @@ Tested on: 0.209.4
4560

4661
## Version history
4762

48-
0.0.1
63+
- __0.0.2__ Added: Get Blob, Delete Blob, Delete Container
64+
- __0.0.1__ Inital version
65+
66+
67+
____
68+
## Build and Run
4969

70+
In the nodes directory:
71+
```
72+
npm run build
73+
npm link
74+
```
5075

76+
In `~/.n8n/nodes`
77+
```
78+
npm link n8n-nodes-azure-blob-storage
79+
n8n start
80+
```

nodes/AzureBlobStorage/AzureBlobDescription.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@ export const containerOperations: INodeProperties[] = [
2626
value: 'getMany',
2727
description: 'List all the containers in a storage account',
2828
action: 'Get many containers',
29+
},
30+
{
31+
name: 'Delete',
32+
value: 'delete',
33+
description: 'Delete a container',
34+
action: 'Delete a container',
2935
},
36+
3037
],
3138

3239
default: 'getMany',
@@ -36,11 +43,12 @@ export const containerOperations: INodeProperties[] = [
3643
name: 'container',
3744
type: 'string',
3845
noDataExpression: true,
46+
required: true,
3947

4048
displayOptions: {
4149
show: {
4250
resource: ['container'],
43-
operation: ['create'],
51+
operation: ['create', 'delete'],
4452
},
4553
},
4654
default: '',
@@ -79,6 +87,12 @@ export const blobOperations: INodeProperties[] = [
7987
value: 'get',
8088
description: 'Get the binary data from a blob',
8189
action: "Get a blob"
90+
},
91+
{
92+
name: 'Delete',
93+
value: 'delete',
94+
description: 'Delete a blob from a container',
95+
action: 'Delete a blob'
8296
}
8397
],
8498

@@ -108,7 +122,7 @@ export const blobOperations: INodeProperties[] = [
108122
displayOptions: {
109123
show: {
110124
resource: ['blob'],
111-
operation: ['upload', 'get'],
125+
operation: ['upload', 'get', 'delete'],
112126
},
113127
},
114128
description:

nodes/AzureBlobStorage/AzureBlobStorage.node.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ export class AzureBlobStorage implements INodeType {
7474

7575
returnData.push(createContainerResponse as IDataObject);
7676
}
77+
else if(operation === 'delete'){
78+
const containerName = this.getNodeParameter('container', i) as string;
79+
const containerClient = blobServiceClient.getContainerClient(containerName);
80+
const deleteContainerResponse = await containerClient.delete();
81+
82+
returnData.push(deleteContainerResponse as IDataObject);
83+
}
7784
} else if (resource === 'blob') {
7885
const containerName = this.getNodeParameter('container', i) as string;
7986
const containerClient = blobServiceClient.getContainerClient(containerName);
@@ -142,6 +149,15 @@ export class AzureBlobStorage implements INodeType {
142149
binaryDataBuffer.length,
143150
);
144151
returnData.push(uploadBlobResponse as IDataObject);
152+
} else if(operation === 'delete'){
153+
const blobName = this.getNodeParameter('blobName', i) as string;
154+
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
155+
const options = {
156+
deleteSnapshots: 'include' // or 'only'
157+
}
158+
159+
const deleteBlobResponse = await blockBlobClient.deleteIfExists(options);
160+
returnData.push(deleteBlobResponse as IDataObject);
145161
}
146162
}
147163
}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "n8n-nodes-azure-blob-storage",
3-
"version": "0.0.1",
3+
"version": "0.0.2",
44
"description": "Node to interact with Azure blob storage. Create/Update/List containers, Create/update/list/delete blobs.",
55
"keywords": [
66
"n8n-community-node-package", "azure", "storage", "blob"

0 commit comments

Comments
 (0)