Rackspace .NET cloudifles API, the GetObjectSaveToFile method gets the file and save it properly in the specified location, but when using GetObject method, if i save the memorystream returned, the file is filled with bunch of nulls.
var cloudFilesProvider = new CloudFilesProvider(cloudIdentity);
cloudFilesProvider.GetObjectSaveToFile(inIntStoreID.ToString(), @"C:\EnetData\Development\Sanbox\OpenStack\OpenStackConsole\testImages\", inStrFileName);
works fine. but when i try
System.IO.Stream outputStream = new System.IO.MemoryStream();
cloudFilesProvider.GetObject(inIntStoreID.ToString(), inStrFileName, outputStream);
FileStream file = new FileStream(strSrcFilePath, FileMode.Create, System.IO.FileAccess.Write);
byte[] bytes = new byte[outputStream.Length];
outputStream.Read(bytes, 0, (int)outputStream.Length);
file.Write(bytes, 0, bytes.Length);
file.Close();
outputStream.Close();
i get a file with bunch of nulls in it.
I think the secret to your problem lies in the return value of
outputStream.Read
- which is likely returning 0.I would try the following code instead: