private string UploadToFlickr(TideTrackerInputModel model) { string flickrId = string.Empty; var flickr = new Flickr(FlickrApiKey, FlickrApiSecret); //var oauthRequestToken = flickr.OAuthGetRequestToken("http://www.witnesskingtides.com/"); //var ouathRequestToken = flickr.OAuthGetRequestToken("http://www.flickr.com/auth-72157638432779974"); var client = new WebClient(); var miniToken = client.DownloadString("http://www.flickr.com/auth-72157638432779974"); //flickr = new Flickr(FlickrApiKey, FlickrApiSecret, oauthRequestToken.Token); //var auth = flickr.OAuthGetAccessToken(oauthRequestToken.Token, oauthRequestToken.TokenSecret, "72157638432779974"); //var auth = flickr.AuthOAuthGetAccessToken(); //using (var memoryStream = new MemoryStream()) //{ // memoryStream.Write(model.Photo, 0, model.Photo.Length); // flickrId = flickr.UploadPicture(memoryStream, model.FileName, null, model.Description, null, true, true, true, ContentType.Photo, SafetyLevel.None, HiddenFromSearch.Visible); //} return flickrId; }
public UploadPhotoResult Post(TideTrackerInputModel inputModel) { var fileId = Guid.NewGuid(); inputModel.FileName = fileId + ".jpg"; var photoPath = Path.Combine(@"G:\Photos", inputModel.FileName); using (var stream = File.Open(photoPath, FileMode.CreateNew, FileAccess.Write)) { stream.Write(inputModel.Photo, 0, inputModel.Photo.Length); } using (var textStream = File.CreateText(Path.Combine(@"G:\Photos", fileId + ".json"))) { textStream.Write(Newtonsoft.Json.JsonConvert.SerializeObject(inputModel, Newtonsoft.Json.Formatting.Indented)); } var result = new UploadPhotoResult { Latitude = inputModel.Latitude, Longitude = inputModel.Longitude }; result.FlickrId = UploadToFlickr(inputModel); return result; }