I'm trying to upload an image on the Blob Storage of Microsoft Azure using SDK V10 in Angular.
The following is the code I currently use to connect to the Storage and list all the containers names:
// connect to the Blob Service
const pipeline = StorageURL.newPipeline(new AnonymousCredential(), {
retryOptions: { maxTries: 4 },
telemetry: { value: "HighLevelSample V1.0.0" }
});
const serviceURL = new ServiceURL(
`${this.blobUri}/${environment.azureContainers.sasToken}`,
pipeline
);
// List containers
let marker;
do {
const listContainersResponse: Models.ServiceListContainersSegmentResponse = await serviceURL.listContainersSegment(
Aborter.none,
marker
);
marker = listContainersResponse.nextMarker;
for (const container of listContainersResponse.containerItems) {
console.log(`Container: ${container.name}`);
}
} while (marker);
Now I would like to upload a file (specifically, a image) in one of the listed containers (doesn't matter which one for the purpose of this question), but from what I have read in the documentation, a filepath is required, but I don't have it. What I have instead is an object of type "File" in JS and, as far as I know, getting a filepath from the browser cannot be done due to security reasons!
Do you have any idea of how to achieve this? How can I upload an image to the Blob Storage in Angular?