Support azure storage (#221)

* azure storage

* azure uploader

* azure uploader

* azure uploader

* fix
This commit is contained in:
Hoan Luu Huu
2023-08-22 07:50:30 -04:00
committed by GitHub
parent 042ad9f629
commit 9d24ef6238
7 changed files with 478 additions and 19 deletions
+20 -1
View File
@@ -1,6 +1,23 @@
const { S3Client, PutObjectCommand, GetObjectCommand } = require('@aws-sdk/client-s3');
const {Storage} = require('@google-cloud/storage');
const fs = require('fs');
const { BlobServiceClient } = require('@azure/storage-blob');
async function testAzureStorage(logger, opts) {
const blobServiceClient = BlobServiceClient.fromConnectionString(opts.connection_string);
const containerClient = blobServiceClient.getContainerClient(opts.name);
const blockBlobClient = containerClient.getBlockBlobClient('jambonz-sample.text');
await blockBlobClient.uploadFile(`${__dirname}/jambonz-sample.text`);
}
async function getAzureStorageObject(logger, opts) {
const blobServiceClient = BlobServiceClient.fromConnectionString(opts.connection_string);
const containerClient = blobServiceClient.getContainerClient(opts.name);
const blockBlobClient = containerClient.getBlockBlobClient(opts.key);
const response = await blockBlobClient.download(0);
return response.readableStreamBody;
}
function testGoogleStorage(logger, opts) {
return new Promise((resolve, reject) => {
@@ -78,5 +95,7 @@ module.exports = {
testAwsS3,
getS3Object,
testGoogleStorage,
getGoogleStorageObject
getGoogleStorageObject,
testAzureStorage,
getAzureStorageObject
};