Пример #1
0
 /// <summary>
 /// 创建临时附件
 /// </summary>
 /// <param name="attachment"></param>
 public static void Create(TemporaryAttachment attachment, Stream stream)
 {
     if (GlobalSettings.IsImage(attachment.FileName))
     {
         try
         {
             ImageInfo info = new ImageInfo(stream);
             info.Check();
             attachment.Width  = info.Width;
             attachment.Height = info.Height;
         }
         catch { }
     }
     attachment.ContentType = MimeTypeManager.GetMimeType(attachment.FileName);
     attachment.ContentSize = stream.Length;
     CommonDataProvider.Instance.CreateUpdateTemporaryAttachment(attachment, DataProviderAction.Create);
     if (stream != null)
     {
         FileStorageProvider fs = new FileStorageProvider(FileStoreKey);
         fs.AddUpdateFile(MakePath(attachment), attachment.FileName, stream);
     }
 }
 /// <summary>
 /// 判断是否图像文件
 /// </summary>
 /// <param name="fileName"></param>
 public static bool IsImage(string fileName)
 {
     return(MimeTypeManager.GetMimeType(fileName).IndexOf("image") > -1);
 }