예제 #1
0
        public IActionResult handleImage(FileUPloadAPI image)
        {
            string token = Request.Form["token"].ToString();

            try
            {
                if (image.files.Length > 0)
                {
                    string savedLocation = FileManager.saveFile(image, token, "", "");

                    if (savedLocation.Equals(null))
                    {
                        return(Forbid("File extension is not valid"));
                    }

                    return(Ok("Saved successfully"));
                }

                return(NotFound("No data to process"));
            }
            catch (Exception ex)
            {
                return(BadRequest(""));
            }
        }
예제 #2
0
 public async Task <string> Post([FromForm] FileUPloadAPI objFile)
 {
     try
     {
         if (objFile.files.Length > 0)
         {
             if (!Directory.Exists(rootFolders))
             {
                 Directory.CreateDirectory(rootFolders);
             }
             using (FileStream fileStream = System.IO.File.Create(rootFolders + objFile.files.FileName.Split('\\').LastOrDefault().Split('/').LastOrDefault()))
             {
                 objFile.files.CopyTo(fileStream);
                 fileStream.Flush();
                 fileStream.Close();
                 string masage = ImportCustomer(objFile.files.FileName);
                 return(masage);
             }
         }
         else
         {
             return("Error file uploads");
         }
     }
     catch (Exception ex) { return(ex.Message.ToString()); }
 }
예제 #3
0
        public bool uploadGPX([FromQuery] string token, [FromQuery] string id, FileUPloadAPI gpx)
        {
            string result = FileManager.saveFile(gpx, token, id, "activity");

            if (!(result == null))
            {
                return(true);
            }

            return(false);
        }
예제 #4
0
        public async Task <string> PostAsync([FromForm] FileUPloadAPI masages)
        {
            try
            {
                string masage = "";
                switch (masages.masage)
                {
                case "ReplisPassword": masage = await ReplisPassword(Convert.ToInt32(masages.Id)); break;

                case "DoubleAutentifity": masage = await DoubleAutentifity(Convert.ToInt32(masages.Id)); break;

                case "NewUser": masage = await NewUser(Convert.ToInt32(masages.Id)); break;
                }
                return(masage);
            }
            catch { return("Error"); }
        }
예제 #5
0
        public async Task <string> PostAsync([FromForm] FileUPloadAPI masages)
        {
            try
            {
                string masage = "";
                switch (masages.masage)
                {
                case "criate_gramots":   masage = criate_gramots(Convert.ToInt32(masages.Id), Convert.ToInt32(masages.Id_patisipant)); break;

                case "criate_daidg": masage = criate_daidg(Convert.ToInt32(masages.Id), Convert.ToInt32(masages.Id_patisipant)); break;

                case "criate_itog": masage = criate_itog(Convert.ToInt32(masages.Id_patisipant)); break;
                }
                return(masage);
            }
            catch { return("Error"); }
        }
예제 #6
0
        public IActionResult handleImage(string username, FileUPloadAPI image)//, [FromQuery] string token)
        {
            try
            {
                if (image.files.Length > 0)
                {
                    string savedLocation = FileManager.saveFile(image, username);

                    if (savedLocation == null)
                    {
                        return(Forbid("File extension is not valid"));
                    }

                    return(Ok("Saved successfully"));
                }

                return(NotFound("No data to process"));
            }
            catch (Exception ex)
            {
                return(BadRequest(""));
            }
        }
예제 #7
0
 public async Task <string> Posts([FromForm] FileUPloadAPI objFile)
 {
     try
     {
         if (objFile.files.Length > 0)
         {
             if (!Directory.Exists(lincs.Images_Folder_Strings() + @"\"))
             {
                 Directory.CreateDirectory(lincs.Images_Folder_Strings() + @"\");
             }
             using (FileStream fileStream = System.IO.File.Create(lincs.Images_Folder_Strings() + @"\" + objFile.files.FileName.Split('\\').LastOrDefault().Split('/').LastOrDefault()))
             {
                 objFile.files.CopyTo(fileStream);
                 fileStream.Flush();
                 return("http://90.189.158.10/ImagesGaleri/" + objFile.files.FileName);
             }
         }
         else
         {
             return("Error file uploads");
         }
     }
     catch (Exception ex) { return(ex.Message.ToString()); }
 }