Hi! I'm not sure were you code fails, but I below is my method for uploading a file. Hope this will help you out.
public static boolean uploadFileToAzureFileStorage(System.IO.Stream _fileContentInStream , str _folderName, str _fileName)
{
SomeParameterTable someParameterTable = SomeParameterTable::find();
try
{
Microsoft.WindowsAzure.Storage.Auth.StorageCredentials storageCredentials = new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(someParameterTable.AzureStorageAccount,someParameterTable.AzureStorageCredentialKey);
Microsoft.WindowsAzure.Storage.CloudStorageAccount storageAccount = new Microsoft.WindowsAzure.Storage.CloudStorageAccount(storageCredentials, true);
Microsoft.WindowsAzure.Storage.File.CloudFileClient fileClient = storageAccount.CreateCloudFileClient();
Microsoft.WindowsAzure.Storage.File.CloudFileShare share = fileClient.GetShareReference(someParameterTable.AzureStorageFileShare);
if (! share.Exists(null, null))
{
throw error(strFmt("Azure file share is missing!", someParameterTable.AzureStorageFileShare, someParameterTable.AzureStorageAccount));
}
Microsoft.WindowsAzure.Storage.File.CloudFileDirectory cloudDir = share.GetRootDirectoryReference();
container conFolders = str2con(_folderName, '/');
for (int i = 1; i <= conlen(conFolders); i++)
{
str folderName = conpeek(conFolders, i);
cloudDir = cloudDir.GetDirectoryReference(folderName);
cloudDir.CreateIfNotExists(null, null);
}
Microsoft.WindowsAzure.Storage.File.CloudFile file = cloudDir.GetFileReference(_fileName);
//have to run Seek on Stream. The file will be empty if not
if (_fileContentInStream.CanSeek)
{
_fileContentInStream.Seek(0, System.IO.SeekOrigin::Begin);
}
file.UploadFromStream(_fileContentInStream,null,null,null);
return true;
}
catch
{
return false;
}
}