public OurTeamPanelVM(IPublishedContent content) { Title = content.GetProperty("title").DataValue.ToString(); SubTitle = content.GetProperty("subTitle").DataValue.ToString(); Text = content.GetProperty("text").DataValue.ToString(); Image = MediaHelpers.GetMediaURL(content.GetProperty("image").DataValue.ToString()); }
public string GetPublicUrl(string path) { path = CleanPath(path); string key = PathToKey(path); string url; if (MediaHelpers.IsPicture(null, path)) { url = string.Format("{0}{1}/{2}", _amazonS3StorageConfiguration.AWSS3PublicUrl, _amazonS3StorageConfiguration.AWSFileBucket, path); url = HttpUtility.UrlPathEncode(url); } else { GetPreSignedUrlRequest preRequest = new GetPreSignedUrlRequest(); preRequest.BucketName = _amazonS3StorageConfiguration.AWSFileBucket; preRequest.Key = key; preRequest.Expires = DateTime.Now.AddMinutes(_amazonS3StorageConfiguration.AWSExpireMinutes); preRequest.Protocol = Protocol.HTTPS; url = _client.GetPreSignedURL(preRequest); } return(url.Replace("\\", "/")); }
public ClientPanelVM(IPublishedContent content) { Id = content.Id; Title = content.GetProperty("title").DataValue.ToString(); Text = content.GetProperty("text").DataValue.ToString(); Image = MediaHelpers.GetMediaURL(content.GetProperty("clientImage").DataValue.ToString()); Order = content.SortOrder; }
public void PicturesArePictures() { Assert.That(MediaHelpers.IsPicture(null, "image.gif"), Is.True); Assert.That(MediaHelpers.IsPicture(null, "image.jpg"), Is.True); Assert.That(MediaHelpers.IsPicture(null, "image.jpeg"), Is.True); Assert.That(MediaHelpers.IsPicture(null, "image.png"), Is.True); Assert.That(MediaHelpers.IsPicture(null, "image.bmp"), Is.True); Assert.That(MediaHelpers.IsPicture(null, "image.ico"), Is.True); }
public async Task <IActionResult> Edit(MediaView result) { if (!ModelState.IsValid) { return(View(result)); } var medium = await _mediaService.Get(result.Id); await _mediaService.Update(MediaHelpers.MergeViewWithModel(medium, result)); return(RedirectToAction("Details", "Media", new { id = result.Id })); }
public void PublishFile(string path) { var key = PathToKey(path); Console.WriteLine("Publish key:" + key); _client.PutACL(new PutACLRequest { BucketName = _amazonS3StorageConfiguration.AWSFileBucket, Key = key, CannedACL = MediaHelpers.IsPicture(null, path) ? S3CannedACL.PublicRead : S3CannedACL.AuthenticatedRead }); }
public ServicesVM(IPublishedContent content) { Id = content.Id; Title = content.GetProperty("title").DataValue.ToString(); Text = content.GetProperty("text").DataValue.ToString(); Image = MediaHelpers.GetMediaURL(content.GetProperty("image").DataValue.ToString()); MenuTitle = content.GetProperty("menuTitle").DataValue.ToString(); HasMenuItem = content.GetProperty("haveMenuItem").DataValue.ToString() == "1"; Order = content.SortOrder; Services = new List <ServicesPanelVM>(); foreach (var child in content.Children) { Services.Add(new ServicesPanelVM(child)); } }
public TopPanelVM(IPublishedContent content) : base(content) { Id = content.Id; Title = content.GetProperty("title").DataValue.ToString(); Text = content.GetProperty("text").DataValue.ToString(); MenuTitle = content.GetProperty("menuTitle").DataValue.ToString(); HasMenuItem = content.GetProperty("haveMenuItem").DataValue.ToString() == "1"; Order = content.SortOrder; SubTitle = content.GetProperty("subTitle").DataValue.ToString(); //var mediaFile = ApplicationContext.Current.Services.MediaService.GetById(int.Parse(content.GetProperty("backgroundImage").DataValue.ToString())); //var url = mediaFile.GetValue("umbracoFile").ToString().Split('\'')[1]; //umbraco.uQuery.GetMedia(content.GetProperty("backgroundImage").DataValue.ToString()).Image;//GetImageUrlById(content.GetProperty("backgroundImage").DataValue.ToString());//; Image = MediaHelpers.GetMediaURL(content.GetProperty("backgroundImage").DataValue.ToString()); Link = content.GetProperty("link").DataValue.ToString(); ButtonText = content.GetProperty("buttonText").DataValue.ToString(); }
public async Task <IActionResult> Edit(string id) { var medium = await _mediaService.Get(id); return(View(MediaHelpers.ConvertToView(medium))); }
/// <summary> /// Add file to database async. /// </summary> /// <param name="path">Path to file.</param> /// <returns>Bool if item was added to the database.</returns> public async Task <bool> AddFileAsync(string path) { try { if (!this.platform.IsFileAvailable(path)) { return(false); } var fileType = Path.GetExtension(path); if (MediaFileExtensions.AudioExtensions.Contains(fileType)) { var trackInDb = await this.musicDatabase.ContainsTrackAsync(path).ConfigureAwait(false); if (trackInDb) { // Already in DB, return. return(true); } var mP = await MediaHelpers.GetMusicPropertiesAsync(this.libVLC, path); if (mP is null || (string.IsNullOrEmpty(mP.Artist) && string.IsNullOrEmpty(mP.Album) && string.IsNullOrEmpty(mP.Title))) { // We couldn't parse the file or the metadata is empty. Skip it. this.OnNewMediaItemError(new NewMediaItemErrorEventArgs() { MediaItemPath = path }); return(false); } var artistName = mP.Artist?.Trim(); var albumArtistName = mP.AlbumArtist?.Trim(); var artist = await this.musicDatabase.FetchArtistViaNameAsync(artistName).ConfigureAwait(false); if (artist is null) { artist = new ArtistItem() { Name = artistName, }; artist = await this.musicDatabase.AddArtistAsync(artist); this.OnNewMediaItemAdded(new NewMediaItemEventArgs(artist)); } var albumName = mP.Album?.Trim(); var album = await this.musicDatabase.FetchAlbumViaNameAsync(artist.Id, albumName); if (album is null) { album = new AlbumItem() { ArtistItemId = artist.Id, Name = albumName, Year = mP.Year, }; album = await this.musicDatabase.AddAlbumAsync(album); this.OnNewMediaItemAdded(new NewMediaItemEventArgs(album)); } mP.AlbumItemId = album.Id; mP.ArtistItemId = artist.Id; mP = await this.musicDatabase.AddTrackAsync(mP).ConfigureAwait(false); this.OnNewMediaItemAdded(new NewMediaItemEventArgs(mP)); return(mP.Id > 0); } else if (MediaFileExtensions.VideoExtensions.Contains(fileType)) { if (await this.videoDatabase.ContainsVideoAsync(path)) { return(true); } var videoItem = await MediaHelpers.GetVideoPropertiesAsync(this.libVLC, path).ConfigureAwait(false); if (!string.IsNullOrEmpty(videoItem.ShowTitle)) { var tvShow = await this.videoDatabase.FetchTVShowViaNameAsync(videoItem.ShowTitle); if (tvShow is null) { tvShow = await this.videoDatabase.AddTVShowAsync(new Model.Video.TVShow() { ShowTitle = videoItem.ShowTitle }).ConfigureAwait(false); this.OnNewMediaItemAdded(new NewMediaItemEventArgs(tvShow)); } videoItem.TvShowId = tvShow.Id; } videoItem = await this.videoDatabase.AddVideoItemAsync(videoItem).ConfigureAwait(false); this.OnNewMediaItemAdded(new NewMediaItemEventArgs(videoItem)); return(videoItem.Id > 0); } this.OnNewMediaItemError(new NewMediaItemErrorEventArgs() { MediaItemPath = path }); return(false); } catch (Exception ex) { this.OnNewMediaItemError(new NewMediaItemErrorEventArgs() { Exception = ex, MediaItemPath = path }); await this.logHelper.LogAsync(LogSeverity.Error, ex.Message, true); } return(false); }
public void PdfIsNotAPicture() { Assert.That(MediaHelpers.IsPicture(null, "notanimage.pdf"), Is.False); }