public bool SaveImage(FishModels.FishImage i) { try { string Id = GetId(); FishDB.spInsertImage(Id, i.FishID, i.thumb.objectKey, i.thumb.url, i.thumb.expires, i.fullSize.objectKey, i.fullSize.url, i.fullSize.expires); return(true); } catch (Exception ex) { error.logError(ex.Message, ex.Source, ex.StackTrace, "Enter Fish", "DatabaseClass", "saveImage", HttpContext.Current.User.Identity.Name, null); return(false); } }
public JsonResult AsyncUpload(IEnumerable <HttpPostedFileBase> files) { int count = 0; //string thumbNail; string fishID = ""; string imageUrl = ""; decimal imageLat = 0; decimal imageLong = 0; DateTime imageDateTime = new DateTime(); if (files != null) { foreach (var file in files) { if (file != null && file.ContentLength > 0 && file.ContentLength / 1000 < 4096) { //resize MemoryStream s1 = resizeImage(file, "thumb"); FishModels.AmazonS3Url thumbUrl = UploadToS3(s1, "thumb"); MemoryStream s2 = resizeImage(file, "1000"); FishModels.AmazonS3Url fullSizeUrl = UploadToS3(s2, "1000"); ////get Exif Data Stream s = file.InputStream; FishModels.ExifData e = GetExifData(s); FishModels.FishImage image = new FishModels.FishImage(); FishModels.NewFishInfo newFishInfo = (FishModels.NewFishInfo)Session["NewFishInfo"]; image.FishID = newFishInfo.fishID; image.ExifData = e; image.thumb = thumbUrl; image.fullSize = fullSizeUrl; //get some stuff from first image only if (count == 0) { imageUrl = fullSizeUrl.url; imageLat = image.ExifData.GPSLatitude; imageLong = image.ExifData.GPSLongitude; imageDateTime = image.ExifData.dateTimeTaken; } //save image data to DB dbClass.SaveImage(image); fishID = image.FishID; // get weather data //getWeatherData(imageLat, imageLong, image.ExifData.dateTimeTaken); } //upload to amazon S3 //save S3 key to DB //get exif data //save exif data to DB //start API calls for weather, water level, etc... //file.SaveAs(path); count++; } } var result = new { url = imageUrl, //imageKey = fishID, latitude = imageLat, longitude = imageLong, imageDate = imageDateTime.ToShortDateString(), imageTime = imageDateTime.ToShortTimeString() }; return(Json(result, JsonRequestBehavior.AllowGet)); }