Open ShreyashPromact opened 9 years ago
I have put question here in below SO link. So if any of your contributor can also reply me over there. http://stackoverflow.com/questions/31847102/upload-file-with-azure-storage-using-sas-shared-access-signature
@ShreyashPromact
Hi, here is how I use the SAS token:
StorageCredentialsSharedAccessSignature SAS = new StorageCredentialsSharedAccessSignature(MainActivity.sasToken);
CloudBlobContainer container = new CloudBlobContainer(SAS.transformUri(new URI("https://
And I guess you can directly pass the blob's URI to the transformUri rather than construct the container first. Also you can refer to the unit tests for more usage examples.
@colorfulben
Thanks for your response. I really appreciate it. I suggest to put/update one example of using SAS for uploading image file because with in your git example code it is mention to upload image file using storage method and key. Now, if there is no example give to use sas to upload image file then people might get confuse about how to use it.
Thanks.
Sincerely, Shreyash
String blobUri = "https://mydomain.blob.core.windows.net/container1/container2/"+blobName; StorageCredentialsSharedAccessSignature SAS = new StorageCredentialsSharedAccessSignature(blobToken); CloudBlockBlob cloudBlockBlob = new CloudBlockBlob(URI.create(blobUri),SAS); cloudBlockBlob.uploadFromFile(imagePath);
This worked for me in Android
This still works today in Kotlin:
private class InitializeUploadTask : AsyncTask<File, Void, Unit>() {
override fun doInBackground(vararg input: File?) {
try {
val storageCredentials = StorageCredentialsSharedAccessSignature("<your token>")
val blockBlob = CloudBlockBlob(URI.create("https://<your host name>/<your container name>/${input[0]?.name}"), storageCredentials)
return blockBlob.uploadFromFile(input[0]?.absolutePath)
}
catch (e: Exception)
{
Log.i("MANAGER", "unexpected")
}
}
}
Hello, I have check your repo. That is more about to upload blob and text file to azure storage server. I have seen your one of the document here that says that you can also use sas to upload the file.
https://azure.microsoft.com/en-us/documentation/articles/storage-dotnet-shared-access-signature-part-2/#part-2-create-a-console-application-to-test-the-shared-access-signatures
Here in one of my client has created method from which i got sas. Now i have to use that sas to upload the file. But i am not getting proper step or way ti use it.
I need some more information on this, If possible i also want to have your repo to be updated with the example of uploading file using sas.
Thanks.
Sincerely, Shreyash