本文整理汇总了C#中IDataStore.GetReadStream方法的典型用法代码示例。如果您正苦于以下问题:C# IDataStore.GetReadStream方法的具体用法?C# IDataStore.GetReadStream怎么用?C# IDataStore.GetReadStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataStore
的用法示例。
在下文中一共展示了IDataStore.GetReadStream方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CrossCopy
///<summary>
/// Copy from one module to another. Can copy from s3 to disk and vice versa
///</summary>
///<param name="srcStore"></param>
///<param name="srcDomain"></param>
///<param name="srcFilename"></param>
///<param name="dstStore"></param>
///<param name="dstDomain"></param>
///<param name="dstFilename"></param>
///<returns></returns>
///<exception cref="ArgumentNullException"></exception>
public static Uri CrossCopy(IDataStore srcStore, string srcDomain, string srcFilename, IDataStore dstStore,
string dstDomain, string dstFilename)
{
if (srcStore == null) throw new ArgumentNullException("srcStore");
if (srcDomain == null) throw new ArgumentNullException("srcDomain");
if (srcFilename == null) throw new ArgumentNullException("srcFilename");
if (dstStore == null) throw new ArgumentNullException("dstStore");
if (dstDomain == null) throw new ArgumentNullException("dstDomain");
if (dstFilename == null) throw new ArgumentNullException("dstFilename");
//Read contents
using (Stream srcStream = srcStore.GetReadStream(srcDomain, srcFilename))
{
using (var memoryStream = TempStream.Create())
{
//Copy
var buffer = new byte[4096];
int readed;
while ((readed = srcStream.Read(buffer, 0, 4096)) != 0)
{
memoryStream.Write(buffer, 0, readed);
}
memoryStream.Position = 0;
return dstStore.Save(dstDomain, dstFilename, memoryStream);
}
}
}
示例2: LoadDataStoreItemData
public static byte[] LoadDataStoreItemData(string domain, string fileLink, IDataStore storage)
{
using (var stream = storage.GetReadStream(domain, fileLink))
{
return stream.GetCorrectBuffer();
}
}
示例3: LoadAttachmentData
private static void LoadAttachmentData(MailAttachment attach, string domain, string file_link, IDataStore current_img_storage)
{
using (var stream = current_img_storage.GetReadStream(domain, file_link))
{
attach.data = stream.GetCorrectBuffer();
}
}