public async Task <HttpResponseMessage> upload_image(Int32 id = 0) { // Verify that this is an HTML Form file upload request if (Request.Content.IsMimeMultipartContent() == false) { return(Request.CreateResponse <string>(HttpStatusCode.UnsupportedMediaType, "The image was not uploaded")); } // Create the directory path string directoryPath = System.Web.HttpContext.Current.Server.MapPath(Tools.GetInspirationImageDirectoryUrl(id)); // Check if the directory exists if (System.IO.Directory.Exists(directoryPath) == false) { // Create the directory System.IO.Directory.CreateDirectory(directoryPath); } // Create a stream provider AnnytabMultipartFormDataStreamProvider streamProvider = new AnnytabMultipartFormDataStreamProvider(directoryPath, ""); // Read the content and upload files await Request.Content.ReadAsMultipartAsync(streamProvider); // Return the success response return(Request.CreateResponse <string>(HttpStatusCode.OK, "The image has been uploaded")); } // End of the upload_image method
public async Task <HttpResponseMessage> upload_other_images(Int32 id = 0, Int32 languageId = 0) { // Verify that this is an HTML Form file upload request if (Request.Content.IsMimeMultipartContent() == false) { return(Request.CreateResponse <string>(HttpStatusCode.UnsupportedMediaType, "Images was not uploaded")); } // Create the directory path string directoryPath = System.Web.HttpContext.Current.Server.MapPath("/Content/products/" + (id / 100).ToString() + "/" + id.ToString() + "/" + languageId.ToString() + "/other_images/"); // Check if the directory exists if (System.IO.Directory.Exists(directoryPath) == false) { // Create the directory System.IO.Directory.CreateDirectory(directoryPath); } // Create a stream provider AnnytabMultipartFormDataStreamProvider streamProvider = new AnnytabMultipartFormDataStreamProvider(directoryPath, ""); // Read the content and upload files await Request.Content.ReadAsMultipartAsync(streamProvider); // Return the success response return(Request.CreateResponse <string>(HttpStatusCode.OK, "Images has been uploaded")); } // End of the upload_other_images method
public async Task<HttpResponseMessage> upload_images() { // Verify that this is an HTML Form file upload request if (Request.Content.IsMimeMultipartContent() == false) { return Request.CreateResponse<string>(HttpStatusCode.UnsupportedMediaType, "Images was not uploaded"); } // Create the directory path string directoryPath = System.Web.HttpContext.Current.Server.MapPath("/Content/campaigns/images/"); // Check if the directory exists if (System.IO.Directory.Exists(directoryPath) == false) { // Create the directory System.IO.Directory.CreateDirectory(directoryPath); } // Create a stream provider AnnytabMultipartFormDataStreamProvider streamProvider = new AnnytabMultipartFormDataStreamProvider(directoryPath, ""); // Read the content and upload files await Request.Content.ReadAsMultipartAsync(streamProvider); // Return the success response return Request.CreateResponse<string>(HttpStatusCode.OK, "Images has been uploaded"); } // End of the upload_images method
public async Task<HttpResponseMessage> upload_main_image(Int32 id = 0, Int32 languageId = 0) { // Verify that this is an HTML Form file upload request if (Request.Content.IsMimeMultipartContent() == false) { return Request.CreateResponse<string>(HttpStatusCode.UnsupportedMediaType, "The image was not uploaded"); } // Create the directory path string directoryPath = System.Web.HttpContext.Current.Server.MapPath("/Content/categories/" + (id / 100).ToString() + "/" + id.ToString() + "/" + languageId.ToString() + "/"); // Check if the directory exists if (System.IO.Directory.Exists(directoryPath) == false) { // Create the directory System.IO.Directory.CreateDirectory(directoryPath); } // Create a stream provider AnnytabMultipartFormDataStreamProvider streamProvider = new AnnytabMultipartFormDataStreamProvider(directoryPath, "main_image.jpg"); // Read the content and upload files await Request.Content.ReadAsMultipartAsync(streamProvider); // Return the success response return Request.CreateResponse<string>(HttpStatusCode.OK, "The image has been uploaded"); } // End of the upload_main_image method