Rackspace的.NET cloudifles API,該GetObjectSaveToFile方法獲取文件,並妥善保存在指定的位置,但使用GetObject方法時,如果我救回來的MemoryStream該文件充滿了大量的空值。使用GetObject的,返回的內存流爲空,而GetObjectSaveToFile返回正確的文件
var cloudFilesProvider = new CloudFilesProvider(cloudIdentity);
cloudFilesProvider.GetObjectSaveToFile(inIntStoreID.ToString(), @"C:\EnetData\Development\Sanbox\OpenStack\OpenStackConsole\testImages\", inStrFileName);
工作正常。但是當我嘗試
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();
我得到一個文件,它有一堆的空值。
燁一遍工作謝謝:) – gopstar