Exemplo n.º 1
0
        public ActionResult Download(long id)
        {
            //return File(Path.Combine(@"c:\path", fileFromDB.FileNameOnDisk), MimeMapping.GetMimeMapping(fileFromDB.FileName), fileFromDB.FileName);
            VendorHelper _Helper = new VendorHelper();
            VendorModel  _model  = new VendorModel();

            _model = _Helper.GetByID(id);
            //string ext = System.IO.Path.GetExtension(Server.MapPath("~/Content/Resources/vendor/" + _model.VendorId + "/" + _model.TradeAndBusinessFile + ""));
            //return File(Path.Combine(Server.MapPath("~/Content/Resources/vendor/" + _model.VendorId + "/" + _model.TradeAndBusinessFile + "")), MimeMapping.GetMimeMapping(_model.TradeAndBusinessFile), _model.ActualTradeAndBusinessFile);

            using (var client = new WebClient())
            {
                try
                {
                    var content = client.DownloadData(AwsS3Bucket.AccessPath() + "/resources/vendor/" + _model.VendorId + "/TradeFile/" + _model.TradeAndBusinessFile);
                    using (var stream = new MemoryStream(content))
                    {
                        byte[] buff = stream.ToArray();
                        return(File(buff, MimeMapping.GetMimeMapping(_model.TradeAndBusinessFile), _model.ActualTradeAndBusinessFile));
                    }
                }
                catch (Exception ex)
                {
                    TempData["CommonMessage"] = AppLogic.setMessage(-1, "Error! try again later.");
                    return(RedirectToAction("Index"));
                }
            }
        }
Exemplo n.º 2
0
 public FileResult Download(ForumModel model)
 {
     using (var client = new WebClient())
     {
         try
         {
             var content = client.DownloadData(AwsS3Bucket.AccessPath() + "/resources/strataboard/" + model.StratasBoardId + "/myforum/" + model.UploadedFileName);
             using (var stream = new MemoryStream(content))
             {
                 byte[] buff = stream.ToArray();
                 return(File(buff, MimeMapping.GetMimeMapping(model.UploadedFileName), model.UploadedFileActualName));
             }
         }
         catch {
         }
     }
     return(null);
 }
Exemplo n.º 3
0
 public FileResult Download(long quotId, string fileName, string actualFileName)
 {
     using (var client = new WebClient())
     {
         try
         {
             var content = client.DownloadData(AwsS3Bucket.AccessPath() + "/resources/vendor-owner-pmb/" + quotId + "/pmbFiles/" + fileName);
             using (var stream = new MemoryStream(content))
             {
                 byte[] buff = stream.ToArray();
                 return(File(buff, MimeMapping.GetMimeMapping(fileName), actualFileName));
             }
         }
         catch (Exception ex)
         {
             TempData["Message"] = AppLogic.setMessage(-1, "Error! " + ex.Message);
         }
     }
     return(null);
 }
Exemplo n.º 4
0
 public FileResult Download(AdminPMBModel model)
 {
     using (var client = new WebClient())
     {
         try
         {
             var content = client.DownloadData(AwsS3Bucket.AccessPath() + "/resources/admin-owner-pmb/" + model.StratasBoardId + "/pmbFiles/" + model.AttachedFileName);
             using (var stream = new MemoryStream(content))
             {
                 byte[] buff = stream.ToArray();
                 return(File(buff, MimeMapping.GetMimeMapping(model.AttachedFileName), model.AttachedFileActualName));
             }
         }
         catch (Exception ex)
         {
             TempData["Message"] = AppLogic.setMessage(-1, "Error! " + ex.Message);
         }
     }
     return(null);
 }