mirror of
https://github.com/jambonz/jambonz-api-server.git
synced 2026-10-09 21:14:00 +00:00
Support azure storage (#221)
* azure storage * azure uploader * azure uploader * azure uploader * fix
This commit is contained in:
@@ -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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user