本文整理汇总了C#中IDataStore.Save方法的典型用法代码示例。如果您正苦于以下问题:C# IDataStore.Save方法的具体用法?C# IDataStore.Save怎么用?C# IDataStore.Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDataStore
的用法示例。
在下文中一共展示了IDataStore.Save方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: ExecResizeImage
private static String ExecResizeImage(byte[] imageData, Size fotoSize, IDataStore dataStore, String photoPath)
{
var data = imageData;
using (var stream = new MemoryStream(data))
using (var img = new Bitmap(stream))
{
var imgFormat = img.RawFormat;
if (fotoSize != img.Size)
{
using (var img2 = Global.DoThumbnail(img, fotoSize))
{
data = Global.SaveToBytes(img2, imgFormat);
}
}
else
{
data = Global.SaveToBytes(img);
}
var fileExtension = String.Concat("." + Global.GetImgFormatName(ImageFormat.Jpeg));
using (var fileStream = new MemoryStream(data))
{
var photoUri = dataStore.Save(photoPath, fileStream).ToString();
photoUri = String.Format("{0}?cd={1}", photoUri, DateTime.UtcNow.Ticks);
return photoUri;
}
}
}
示例3: FileContentSave
private static void FileContentSave(IDataStore storage, string location, byte[] fileContent, WikiSection section)
{
using (var ms = new IO.MemoryStream(fileContent))
{
storage.Save(section.DataStorage.DefaultDomain, location, ms);
}
}
示例4: ResizeLogo
private static void ResizeLogo(CoBrandingLogoTypeEnum type, String fileName, byte[] data, long maxFileSize, Size size, IDataStore store)
{
//Resize synchronously
if (data == null || data.Length <= 0) throw new UnknownImageFormatException();
if (maxFileSize != -1 && data.Length > maxFileSize) throw new ImageWeightLimitException();
try
{
using (var stream = new MemoryStream(data))
using (var img = Image.FromStream(stream))
{
var imgFormat = img.RawFormat;
if (size != img.Size)
{
using (var img2 = CommonPhotoManager.DoThumbnail(img, size, false, true, false))
{
data = CommonPhotoManager.SaveToBytes(img2);
}
}
else
{
data = CommonPhotoManager.SaveToBytes(img);
}
//fileExt = CommonPhotoManager.GetImgFormatName(imgFormat);
using (var stream2 = new MemoryStream(data))
{
store.Save(fileName, stream2);
//NOTE: Update cache here
//var filePath = Path.GetFileName(photoUrl);
//AddToCache(item.UserId, item.Size, fileNPath, true);
}
}
}
catch (ArgumentException error)
{
throw new UnknownImageFormatException(error);
}
}