Beispiel #1
0
        public void Add(MediaContent content, bool overrided)
        {
            if (content.ContentFile != null)
            {

                content.FileName = content.ContentFile.FileName;

                content.UserKey = content.FileName;
                content.UUID = content.FileName;

                // if the file already exist and dont need to overrided just return
                if (content.Exist() && !overrided)
                {
                    return;
                }

                var contentPath = new MediaContentPath(content);

                content.VirtualPath = contentPath.VirtualPath;

                locker.EnterWriteLock();

                try
                {
                    content.ContentFile.Stream.SaveAs(contentPath.PhysicalPath);
                }
                finally
                {
                    locker.ExitWriteLock();
                }

                SetFilePublished(contentPath.PhysicalPath, content.Published);

                metadataStorage.SaveMetadata(content);
            }
        }
Beispiel #2
0
        public void Move(MediaFolder sourceFolder, string oldFileName, MediaFolder targetFolder, string newFileName)
        {
            var oldMediaContent = new MediaContent() { Repository = sourceFolder.Repository.Name, FolderName = sourceFolder.FullName, UUID = oldFileName, FileName = oldFileName };
            var newMediaContent = new MediaContent() { Repository = targetFolder.Repository.Name, FolderName = targetFolder.FullName, UUID = newFileName, FileName = newFileName };

            var oldPath = new MediaContentPath(oldMediaContent);
            var newPath = new MediaContentPath(newMediaContent);

            File.Move(oldPath.PhysicalPath, newPath.PhysicalPath);

            metadataStorage.MoveMetadata(oldMediaContent, newMediaContent);
        }
Beispiel #3
0
        public void Update(Models.MediaContent @new, Models.MediaContent old)
        {
            var contentPath = new MediaContentPath(@new);

            if ([email protected](old.FileName, StringComparison.OrdinalIgnoreCase))
            {
                Kooboo.IO.IOUtility.RenameFile(old.PhysicalPath, @new.FileName);
            }
            if (@new.ContentFile != null)
            {

                @new.FileName = @new.ContentFile.FileName;

                @new.UserKey = @new.FileName;
                @new.UUID = @new.FileName;

                locker.EnterWriteLock();
                try
                {
                    @new.ContentFile.Stream.SaveAs(contentPath.PhysicalPath);
                }
                finally
                {
                    locker.ExitWriteLock();
                }

            }

            SetFilePublished(contentPath.PhysicalPath, @new.Published);
            metadataStorage.SaveMetadata(@new);
        }
Beispiel #4
0
 /// <summary>
 /// Exists the specified content.
 /// </summary>
 /// <param name="content">The content.</param>
 /// <returns></returns>
 public static bool Exist(this MediaContent content)
 {
     var contentPath = new MediaContentPath(content);
     return File.Exists(contentPath.PhysicalPath);
 }