Exemplo n.º 1
0
        /// <summary>
        /// Create a new DroppedFile object.
        /// </summary>
        /// <param name="id">Initial value of the id property.</param>
        public static DroppedFile CreateDroppedFile(global::System.Int32 id)
        {
            DroppedFile droppedFile = new DroppedFile();

            droppedFile.id = id;
            return(droppedFile);
        }
Exemplo n.º 2
0
        public ActionResult Upload()
        {
            ContentResult c = new ContentResult();
            if (Request.Form["value"] != null && Request.Form["name"] != null)
            {
                try
                {
                    //TODO: change file name to (G|U)UID perhaps?
                    string b64_data = (Request.Form["value"].Split(',')[1]).Replace(' ', '+');
                    string baseDir = Path.Combine(Server.MapPath("/"), this._imageDirectoryPrefix);
                    string fileName = Path.GetFileName(Request.Form["name"]);
                    string path = baseDir + fileName;
                    //check if dir exists, if not: make it
                    if (!System.IO.File.Exists(baseDir))
                        System.IO.Directory.CreateDirectory(baseDir);
                    System.IO.File.WriteAllBytes(path, Convert.FromBase64String(b64_data));
                    // now create model
                    DroppedFile d = new DroppedFile()
                    {
                        FName = fileName,
                        DateCreated = DateTime.Now
                    };

                    _fileDropEntities.DroppedFiles.AddObject(d);
                    _fileDropEntities.SaveChanges();

                    c.Content = fileName + ":uploaded successfully:" + d.id;
                }
                catch (Exception e)
                {
                    c.Content = "-1";
                }
            }
            else
                c.Content = "-1";

            return c;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the DroppedFiles EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDroppedFiles(DroppedFile droppedFile)
 {
     base.AddObject("DroppedFiles", droppedFile);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Create a new DroppedFile object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 public static DroppedFile CreateDroppedFile(global::System.Int32 id)
 {
     DroppedFile droppedFile = new DroppedFile();
     droppedFile.id = id;
     return droppedFile;
 }
Exemplo n.º 5
0
 /// <summary>
 /// Deprecated Method for adding a new object to the DroppedFiles EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToDroppedFiles(DroppedFile droppedFile)
 {
     base.AddObject("DroppedFiles", droppedFile);
 }