Adarsh Madrecha
Adarsh Madrecha

Reputation: 7906

Storing Data in firebase using VBA

Is there any way to upload files using VBA to firebase?

Web code for uploading files in firebase

var storageRef = firebase.storage.ref("folderName/file.jpg");
var fileUpload = document.getElementById("fileUpload");
fileUpload.on(‘change’, function(evt) {
  var firstFile = evt.target.file[0]; // get the first file uploaded
  var uploadTask = storageRef.put(firstFile);
  uploadTask.on(‘state_changed’, function progress(snapshot) {
     console.log(snapshot.totalBytesTransferred); // progress of upload
  });
});

But how do I use this in VBA? any help is appreciated. Also if you can point to me in right direction.

Upvotes: 1

Views: 2865

Answers (2)

Pankaj Kumar
Pankaj Kumar

Reputation: 198

I did some research on Firebase. Currently you cannot use VBA to upload files directly to FB Storage, through API.

You can try using JS, as mentioned by you.

Another alternative will be Google Cloud Storage. Which is the back-end for firebase storage.

Upvotes: 2

Krish
Krish

Reputation: 5917

two ways of doing this.. Assuming there is a website where you can upload files, in such case you can use the standard IE object to navigate to a specific website, find the controls, select the files and using submit or click function upload the file..

The other way is to write a web-service and call it from vba. Both suggestions involves in calling the website/service.

Dim IE As Object
Set IE = CreateObject("internetexplorer.application")
IE.Navigate "Your upload page.."

Do While IE.ReadyState <> 4 Or IE.Busy = True
    DoEvents
Loop

we don't have enough information so I just continue with the logic.

  • Find the upload document/filename field. insert your filename
    • IE.Document.getElementById("txt_upload_field").Value = myFileName
  • find the button/element to upload and perform click/submit action.
  • wait for your website and read the result

or you can write your own web service and perform a web-request using XMLHTTP. I personally would go for web-service.

there is also a third way. FTPing to your server..!

Upvotes: 1

Related Questions