CloudFile cloudFile = fileDirectory.GetFileReference(_args.getAttachmentName());
CloudBlockBlob blockBlob = directory.GetBlockBlobReference(strFmt(_args.getAttachmentName()));
StorageCredentials storageCredentials = new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(credentialTable.AccountName, azKey); //Auth
CloudStorageAccount storageAccount = new Microsoft.WindowsAzure.Storage.CloudStorageAccount(storageCredentials, true);
CloudFileClient fileClient = storageAccount.CreateCloudFileClient();
CloudFileShare root = fileClient.GetShareReference('fileShareRoot'); //name of the file share
if(!root.Exists(null, null))
{
return Checkfailed('Azure storage parameters are not set up correctly.');
}
CloudFileDirectory fileDirectory = root.GetRootDirectoryReference();
fileDirectory.GetDirectoryReference('testFolder'); //folder in file share where the file should be uploaded
CloudFile cloudFile = fileDirectory.GetFileReference(_args.getAttachmentName());
if (_fileStream.CanSeek)
{
_fileStream.Seek(0, System.IO.SeekOrigin::Begin);
}
cloudFile.UploadFromStream(_fileStream, null, null, null); //here the Bad Request error is thrown
StorageCredentials credentials = new StorageCredentials(credentialTable.AccountName, azKey);
CloudStorageAccount storageAccount = new CloudStorageAccount(credentials, true);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer rootContainer = blobClient.GetContainerReference('testcon'); //Blob container name
if(!rootContainer.Exists(null, null))
{
return Checkfailed('Azure storage parameters are not set up correctly.');
}
CloudBlobDirectory directory = rootContainer.GetDirectoryReference('testdir'); // folder name under container where file is uploaded
CloudBlockBlob blockBlob = directory.GetBlockBlobReference(strFmt(_args.getAttachmentName()));
if (_fileStream.CanSeek)
{
_fileStream.Seek(0, System.IO.SeekOrigin::Begin);
}
blockBlob.UploadFromStream(_fileStream, null, null, null);
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal...
287,773
Super User
Martin Dráb
225,513
Super User
nmaenpaa
101,148