Azure / azure-storage-java

Microsoft Azure Storage Library for Java

Home Page:https://docs.microsoft.com/en-us/java/api/overview/azure/storage

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Folder with container name is always constructed.

JardarM opened this issue · comments

We are using SDK v12 (12.8.0) and uploading blob files to azure storage.

The problem is that the API seems to create a "root" folder for the container, which seems odd.

The code below creates this file in container box:
box/test/myfile.txt
while I would expect this:
test/myfile.txt

var localfile = "test.txt";
var containerName = "box";
var file = "test/myfile.txt";
var sc = new StorageCredentialsSharedAccessSignature(sasToken.Token);
var container = new CloudBlobClient(URI.create(sasToken.Uri),sc).getContainerReference(containerName);
var blobRef = container.getBlockBlobReference(file);
blobRef.uploadFromFile(localfile)