Skip to content

Commit

Permalink
Get & Delete Blob, Delete container
Browse files Browse the repository at this point in the history
  • Loading branch information
pregress committed Jan 8, 2023
1 parent ce5c3ed commit 1f7b75d
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 6 deletions.
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
![Banner image](https://user-images.githubusercontent.com/10284570/173569848-c624317f-42b1-45a6-ab09-f0ea3c247648.png)

# n8n-nodes-azure-blob-storage

![Build](https://github.com/pregress/n8n-nodes-azure-blob-storage/actions/workflows/build.yml/badge.svg)
[![NPM version][npm-version-image]][npm-url]
[![NPM downloads][npm-downloads-image]][npm-downloads-url]

[npm-url]: https://npmjs.org/package/n8n-nodes-azure-blob-storage
[npm-version-image]: https://img.shields.io/npm/v/n8n-nodes-azure-blob-storage.svg?style=flat
[npm-downloads-image]: https://img.shields.io/npm/dm/n8n-nodes-azure-blob-storage.svg?style=flat
[npm-downloads-url]: https://npmcharts.com/compare/n8n-nodes-azure-blob-storage?minimal=true


This is an n8n community node. It lets you use Azure blob storage in your n8n workflows.

Azure Blob Storage is Microsoft's object storage solution for the cloud. Blob storage is optimized for storing massive amounts of unstructured data.
Expand All @@ -23,9 +35,12 @@ Follow the [installation guide](https://docs.n8n.io/integrations/community-nodes
- Containers
- List
- Create
- Delete
- Blobs
- List
- Upload
- Get
- Delete


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

## Version history

0.0.1
- __0.0.2__ Added: Get Blob, Delete Blob, Delete Container
- __0.0.1__ Inital version


____
## Build and Run

In the nodes directory:
```
npm run build
npm link
```

In `~/.n8n/nodes`
```
npm link n8n-nodes-azure-blob-storage
n8n start
```
18 changes: 16 additions & 2 deletions nodes/AzureBlobStorage/AzureBlobDescription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ export const containerOperations: INodeProperties[] = [
value: 'getMany',
description: 'List all the containers in a storage account',
action: 'Get many containers',
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a container',
action: 'Delete a container',
},

],

default: 'getMany',
Expand All @@ -36,11 +43,12 @@ export const containerOperations: INodeProperties[] = [
name: 'container',
type: 'string',
noDataExpression: true,
required: true,

displayOptions: {
show: {
resource: ['container'],
operation: ['create'],
operation: ['create', 'delete'],
},
},
default: '',
Expand Down Expand Up @@ -79,6 +87,12 @@ export const blobOperations: INodeProperties[] = [
value: 'get',
description: 'Get the binary data from a blob',
action: "Get a blob"
},
{
name: 'Delete',
value: 'delete',
description: 'Delete a blob from a container',
action: 'Delete a blob'
}
],

Expand Down Expand Up @@ -108,7 +122,7 @@ export const blobOperations: INodeProperties[] = [
displayOptions: {
show: {
resource: ['blob'],
operation: ['upload', 'get'],
operation: ['upload', 'get', 'delete'],
},
},
description:
Expand Down
16 changes: 16 additions & 0 deletions nodes/AzureBlobStorage/AzureBlobStorage.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ export class AzureBlobStorage implements INodeType {

returnData.push(createContainerResponse as IDataObject);
}
else if(operation === 'delete'){
const containerName = this.getNodeParameter('container', i) as string;
const containerClient = blobServiceClient.getContainerClient(containerName);
const deleteContainerResponse = await containerClient.delete();

returnData.push(deleteContainerResponse as IDataObject);
}
} else if (resource === 'blob') {
const containerName = this.getNodeParameter('container', i) as string;
const containerClient = blobServiceClient.getContainerClient(containerName);
Expand Down Expand Up @@ -142,6 +149,15 @@ export class AzureBlobStorage implements INodeType {
binaryDataBuffer.length,
);
returnData.push(uploadBlobResponse as IDataObject);
} else if(operation === 'delete'){
const blobName = this.getNodeParameter('blobName', i) as string;
const blockBlobClient = containerClient.getBlockBlobClient(blobName);
const options = {
deleteSnapshots: 'include' // or 'only'
}

const deleteBlobResponse = await blockBlobClient.deleteIfExists(options);
returnData.push(deleteBlobResponse as IDataObject);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "n8n-nodes-azure-blob-storage",
"version": "0.0.1",
"version": "0.0.2",
"description": "Node to interact with Azure blob storage. Create/Update/List containers, Create/update/list/delete blobs.",
"keywords": [
"n8n-community-node-package", "azure", "storage", "blob"
Expand Down

0 comments on commit 1f7b75d

Please sign in to comment.