Hello, I’m new to Bubble and am attempting to upload files(pdf and zip) from Bubble to Azure Blob storage. I tried using the Bubble file uploader plugin, but it states it only supports Amazon S3 and Box as file storage.
I tried the API connector plugin and was able to submit a JSON-formatted API to Azure and receive a response. But, I couldn’t find any plugins to upload the files to Azure blob storage.
Could someone please tell me whether there is a way to upload files from Bubble to Azure Blob storage?
1 Like
Hello,
I haven’t seen a plugin for Azure, however I developed an example code that will do this for you. Note that this is using a server-side action so that the npm library can be imported.
I didn’t write a full solution for you, but hopefully you can use the code to get you on your way.
function(properties, context) {const { BlobServiceClient } = require("@azure/storage-blob");
const containerName = "workflows";
const AZURE_STORAGE_CONNECTION_STRING = properties.azurestorageconnectionstring;
const blobServiceClient = BlobServiceClient.fromConnectionString(
AZURE_STORAGE_CONNECTION_STRING
); const containerClient = blobServiceClient.getContainerClient(containerName);
// Incantation to request content
var getoptions = {
uri: 'https:' + properties.image,
method: "GET",
encoding: null,
headers: { "Accept": "application/octet-stream" }
};
// Store the bytes
var filebytes = context.request(getoptions).body;
var imageData = Buffer.from(filebytes);
// console.log(imageData);
const workflowBlockBlobClient = containerClient.getBlockBlobClient('plugin-testing/images/test.jpeg');
workflowBlockBlobClient.upload(imageData, imageData.length); }
Have you found solutions regarding Azure Blob?
Can you clarify? The code I posted above is a working solution for uploading files to Azure Blob Storage.
Are you asking for a fully built plugin?
I am quite new to Bubble, may I know how do you exactly utilize this code for files uploading to Azure Blob? Does it work similar to API or Plugins? Does it also work with Azure Files?