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);
André Arnaud de Cal... 291,642 Super User 2024 Season 2
Martin Dráb 230,371 Most Valuable Professional
nmaenpaa 101,156