@@ -85,6 +85,36 @@ export class AzureBlobStorage implements INodeType {
8585 arr . push ( blob ) ;
8686 }
8787 returnData . push . apply ( returnData , arr as IDataObject [ ] ) ;
88+ } else if ( operation === 'get' ) {
89+ const blobName = this . getNodeParameter ( 'blobName' , i ) as string ;
90+ const blockBlobClient = containerClient . getBlockBlobClient ( blobName ) ;
91+ const downloadBlockBlobResponse = await blockBlobClient . download ( ) ;
92+
93+ const newItemBinary : IBinaryKeyData = { } ;
94+ const buffer = await streamToBuffer ( downloadBlockBlobResponse . readableStreamBody ) as Buffer ;
95+ newItemBinary . data = await this . helpers . prepareBinaryData ( buffer ) ;
96+ newItemBinary . data . mimeType = downloadBlockBlobResponse . contentType ;
97+
98+ returnData . push ( {
99+ json : {
100+ "blobName" : blobName ,
101+ "blobType" : downloadBlockBlobResponse . blobType ,
102+ "contentEncoding" : downloadBlockBlobResponse . contentEncoding ,
103+ "contentLanguage" : downloadBlockBlobResponse . contentLanguage ,
104+ "contentLength" : downloadBlockBlobResponse . contentLength ,
105+ "contentType" : downloadBlockBlobResponse . contentType ,
106+ "lastAccessed" : downloadBlockBlobResponse . lastAccessed ,
107+ "lastModified" : downloadBlockBlobResponse . lastModified ,
108+ "leaseDuration" : downloadBlockBlobResponse . leaseDuration ,
109+ "leaseState" : downloadBlockBlobResponse . leaseState ,
110+ "leaseStatus" : downloadBlockBlobResponse . leaseStatus ,
111+ } ,
112+ pairedItem : {
113+ item : i ,
114+ } ,
115+ binary : Object . keys ( newItemBinary ) . length === 0 ? undefined : newItemBinary ,
116+ } ) ;
117+
88118 } else if ( operation === 'upload' ) {
89119 const binaryPropertyName = this . getNodeParameter ( 'binaryPropertyName' , i ) as string ;
90120
@@ -131,3 +161,17 @@ export class AzureBlobStorage implements INodeType {
131161 return [ this . helpers . returnJsonArray ( returnData ) ] ;
132162 }
133163}
164+
165+
166+ async function streamToBuffer ( readableStream : NodeJS . ReadableStream ) {
167+ return new Promise ( ( resolve , reject ) => {
168+ const chunks : Buffer [ ] = [ ] ;
169+ readableStream . on ( "data" , ( data : WithImplicitCoercion < ArrayBuffer | SharedArrayBuffer > ) => {
170+ chunks . push ( data instanceof Buffer ? data : Buffer . from ( data ) ) ;
171+ } ) ;
172+ readableStream . on ( "end" , ( ) => {
173+ resolve ( Buffer . concat ( chunks ) ) ;
174+ } ) ;
175+ readableStream . on ( "error" , reject ) ;
176+ } ) ;
177+ }
0 commit comments