public StoreCloudItemForm(StoreCloudItem item)
 {
     this.IDItem      = item.IDItem;
     this.IDStore     = item.IDStore;
     this.LabelFile   = item.LabelFile;
     this.NameFile    = item.NameFile;
     this.VirtualPath = item.VirtualPath;
 }
        /// <summary>
        /// Editer fichier
        /// </summary>
        /// <param name="idItem">id fichier</param>
        /// <returns></returns>
        public ActionResult EditerFichier(long id)
        {
            StoreCloudItem     file = storeCloudProvider.GetFile(id);
            StoreCloudItemForm frm  = new StoreCloudItemForm {
                IDItem = file.IDItem, LabelFile = file.LabelFile, NameFile = file.NameFile
            };

            return(PartialView(frm));
        }
        /// <summary>
        /// Preview image
        /// </summary>
        /// <param name="idstore">id store</param>
        /// /// <param name="Idfile">id fichier</param>
        /// <returns></returns>
        public FileStreamResult ImagePreview(int idstore, long Idfile)
        {
            try
            {
                StoreCloudItem file = storeCloudProvider.GetFile(Idfile);
                if (file == null)
                {
                    return(null);
                }
                Stream streamfile = storeCloudProvider.DownloadFile(file);

                return(File(streamfile, file.NameFile));
            }
            catch (Exception)
            {
                return(null);
            }
        }
        public ActionResult UploadImage(string path)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(path))
                {
                    throw new Exception("Path Empty");
                }
                foreach (string upload in Request.Files)
                {
                    HttpPostedFileBase file = Request.Files[upload];
                    if (file == null || file.ContentLength <= 0 || file.ContentLength > (1024 * 500))
                    {
                        throw new Exception("Taille image dépasse 500 ko");
                    }
                    HttpPostedFileBase postedFile = Request.Files[upload];
                    byte[]             buf        = new byte[postedFile.InputStream.Length];
                    postedFile.InputStream.Read(buf, 0, (int)postedFile.InputStream.Length);
                    MemoryStream          ms  = new MemoryStream(buf);
                    System.Drawing.Bitmap btp = new System.Drawing.Bitmap(ms);
                    if (btp == null || btp.Size.Height < 400 || btp.Size.Width < 600)
                    {
                        throw new Exception("Dimension image inférieur à 400x600");
                    }
                    Stream stream = new MemoryStream();
                    btp.Save(stream, System.Drawing.Imaging.ImageFormat.Jpeg);
                    stream.Position = 0;
                    StoreCloudItem img = storeCloudProvider.UploadFile(GetStoreCloud(), path, stream, postedFile.FileName);

                    ViewBag.Files = storeCloudProvider.GetItemsByDirectory(GetStoreCloud(), path);
                    ViewBag.path  = path;
                }
                PageInfo.CreateAlert("Upload image terminé", 2);
            }
            catch (Exception ex)
            { PageInfo.CreateAlert(ex.Message, 4); }
            return(RedirectToAction("Index", new { path = path }));
        }
        /// <summary>
        /// Telecharger
        /// </summary>
        /// <param name="idItem">id fichier</param>
        /// <returns></returns>
        public FileStreamResult Download(string idItem)
        {
            StoreCloudItem file = storeCloudProvider.GetFile(long.Parse(idItem));

            return(File(storeCloudProvider.DownloadFile(GetStoreCloud(), file.IDPhysicalFile), file.NameFile));
        }