当前位置: 首页>>代码示例>>C#>>正文


C# IDataStore.Save方法代码示例

本文整理汇总了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);
                }
            }
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:38,代码来源:CrossModuleCopy.cs

示例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;
                }
            }
        }
开发者ID:haoasqui,项目名称:ONLYOFFICE-Server,代码行数:29,代码来源:OrganisationLogoManager.cs

示例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);
     }
 }
开发者ID:ridhouan,项目名称:teamlab.v6.5,代码行数:7,代码来源:EditFile.ascx.cs

示例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);
            }
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:41,代码来源:TenantCoBrandingSettings.cs


注:本文中的IDataStore.Save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。