Class MediaFileInfoProvider
- Namespace
- CMS.MediaLibrary
- Assembly
- CMS.MediaLibrary.dll
Class providing media file info management.
[ProviderInterface(typeof(IMediaFileInfoProvider))]
[Obsolete("Media libraries and their APIs are obsolete and will be discontinued in the future. Please migrate all media library files to Content hub and use their corresponding content item APIs.")]
public class MediaFileInfoProvider : AbstractInfoProvider<MediaFileInfo, MediaFileInfoProvider>, IInfoProvider, ICustomizableProvider, IBulkOperationProvider, IWebFarmProvider, IInfoValidator<MediaFileInfo>, IInfoByNameProvider<MediaFileInfo>, IBulkInfoProvider<MediaFileInfo>, IMediaFileInfoProvider, IInfoProvider<MediaFileInfo>, IInfoByIdProvider<MediaFileInfo>, IInfoByGuidProvider<MediaFileInfo>
- Inheritance
-
objectMediaFileInfoProvider
- Implements
- Inherited Members
- Extension Methods
Constructors
MediaFileInfoProvider()
Creates new instance of MediaFileInfoProvider.
public MediaFileInfoProvider()
Methods
CanResizeImage(MediaFileInfo, int, int, int)
Checks whether the image should be processed (resized) by the Image manager (if the destination size is smaller).
public static bool CanResizeImage(MediaFileInfo fileInfo, int width, int height, int maxSideSize)
Parameters
fileInfoMediaFileInfoMedia file info to check
widthintNew width
heightintNew height
maxSideSizeintMax side size
Returns
- bool
CanResizeImage(string, int, int, int)
Checks whether the image should be processed (resized) by the Image manager (if the destination size is smaller).
public static bool CanResizeImage(string filePath, int width, int height, int maxSideSize)
Parameters
filePathstringFile path
widthintNew width
heightintNew height
maxSideSizeintMax side size
Returns
- bool
CopyMediaFile(int, string, string, bool, int)
Copy media file.
public static void CopyMediaFile(int libraryID, string origPath, string newPath, bool synchronization = false, int userId = 0)
Parameters
libraryIDintLibrary ID
origPathstringOld file path within the library folder
newPathstringNew file path within the library folder
synchronizationboolIndicates if method is running by web farms synchronization
userIdintID of the user performing copy action
CopyMediaFileInternal(int, string, string, bool, int)
Copy media file.
protected virtual void CopyMediaFileInternal(int libraryID, string origPath, string newPath, bool synchronization, int userId)
Parameters
libraryIDintLibrary ID
origPathstringOld file path within the library folder
newPathstringNew file path within the library folder
synchronizationboolIndicates if method is running by web farms synchronization
userIdintID of the user performing copy action
Delete(MediaFileInfo)
Deletes the info object from the underlying data store.
public override void Delete(MediaFileInfo info)
Parameters
infoMediaFileInfoInfo object to be deleted.
Exceptions
- ArgumentNullException
Thrown when
infois null.
DeleteMediaFile(int, string, bool, bool)
Deletes media file from file system.
public static void DeleteMediaFile(int libraryId, string filePath, bool onlyFile = false, bool synchronization = false)
Parameters
libraryIdintLibrary id
filePathstringSub path to file
onlyFileboolIndicates if only file should be deleted
synchronizationboolIndicates if method is running by web farms synchronization
DeleteMediaFileInternal(int, string, bool, bool)
Deletes media file from filesystem.
protected virtual void DeleteMediaFileInternal(int libraryID, string filePath, bool onlyFile, bool synchronization)
Parameters
libraryIDintLibrary id
filePathstringSub path to file
onlyFileboolIndicates if only file should be deleted
synchronizationboolIndicates if method is running by web farms synchronization
DeleteMediaFilePreview(int, string, bool)
Deletes media file preview from file system.
public static void DeleteMediaFilePreview(int libraryId, string filePath, bool synchronization = false)
Parameters
libraryIdintLibrary ID
filePathstringFile path
synchronizationboolIndicates if method is running by web farms synchronization
DeleteMediaFilePreviewInternal(int, string, bool)
Deletes media file preview from filesystem.
protected virtual void DeleteMediaFilePreviewInternal(int libraryID, string filePath, bool synchronization)
Parameters
libraryIDintLibrary ID
filePathstringFile path
synchronizationboolIndicates if method is running by web farms synchronization
DeleteMediaFilePreviewThumbnails(MediaFileInfo)
Deletes media file preview thumbnails.
public static void DeleteMediaFilePreviewThumbnails(MediaFileInfo fileInfo)
Parameters
fileInfoMediaFileInfoFile info
DeleteMediaFilePreviewThumbnailsInternal(MediaFileInfo)
Deletes media file preview thumbnails.
protected virtual void DeleteMediaFilePreviewThumbnailsInternal(MediaFileInfo fileInfo)
Parameters
fileInfoMediaFileInfoFile info
DeleteMediaFileThumbnails(MediaFileInfo)
Deletes media file thumbnails.
public static void DeleteMediaFileThumbnails(MediaFileInfo fileInfo)
Parameters
fileInfoMediaFileInfoFile info
DeleteMediaFileThumbnailsInternal(MediaFileInfo)
Deletes media file thumbnails.
protected virtual void DeleteMediaFileThumbnailsInternal(MediaFileInfo fileInfo)
Parameters
fileInfoMediaFileInfoFile info
DeleteMediaFiles(string, int)
Deletes file records of files matching specified criteria.
public static void DeleteMediaFiles(string path, int libraryId)
Parameters
pathstringPath of the files to delete
libraryIdintID of the library where the files belongs to
DeleteMediaFilesInternal(string, int)
Deletes file records of files matching specified criteria.
protected virtual void DeleteMediaFilesInternal(string path, int libraryId)
Parameters
pathstringPath of the files to delete
libraryIdintID of the library where the files belongs to
EnsureThumbnailFile(MediaFileInfo, int, int, int, bool)
Ensures the thumbnail file.
public static string EnsureThumbnailFile(MediaFileInfo fileInfo, int width = 0, int height = 0, int maxSideSize = 0, bool usePreview = false)
Parameters
fileInfoMediaFileInfoFile info
widthintFile width
heightintFile height
maxSideSizeintMaximum side size
usePreviewboolUse preview file
Returns
- string
EnsureThumbnailFileInternal(MediaFileInfo, int, int, int, bool)
Ensures the thumbnail file.
protected virtual string EnsureThumbnailFileInternal(MediaFileInfo fileInfo, int width, int height, int maxSideSize, bool usePreview = false)
Parameters
fileInfoMediaFileInfoFile info
widthintFile width
heightintFile height
maxSideSizeintMaximum side size
usePreviewboolUse preview file
Returns
- string
GetDependencyCacheKeys(MediaFileInfo, bool)
Gets the cache key dependencies array for the media file (cache item keys affected when the meta file changes).
public static string[] GetDependencyCacheKeys(MediaFileInfo fi, bool preview)
Parameters
fiMediaFileInfoFile
previewboolIndicates if preview cache key should be created
Returns
- string[]
GetDependencyCacheKeysInternal(MediaFileInfo, bool)
Gets the cache key dependencies array for the media file (cache item keys affected when the meta file changes).
protected virtual string[] GetDependencyCacheKeysInternal(MediaFileInfo fi, bool preview)
Parameters
fiMediaFileInfoFile
previewboolIndicates if preview cache key should be created
Returns
- string[]
GetFile(MediaFileInfo, string)
Returns the file from disk or (if not available on the disk) from database.
public static byte[] GetFile(MediaFileInfo fileInfo, string libraryFolder)
Parameters
fileInfoMediaFileInfoFile info
libraryFolderstringLibrary folder
Returns
- byte[]
GetFileInternal(MediaFileInfo, string)
Returns the file from disk or (if not available on the disk) from database.
protected virtual byte[] GetFileInternal(MediaFileInfo fileInfo, string libraryFolder)
Parameters
fileInfoMediaFileInfoFile info
libraryFolderstringLibrary folder
Returns
- byte[]
GetImageThumbnail(MediaFileInfo, string, int, int, int)
Returns image thumbnail from the disk or create a new one if doesn't exist yet.
public static byte[] GetImageThumbnail(MediaFileInfo fileInfo, string libraryFolder, int width = 0, int height = 0, int maxSideSize = 0)
Parameters
fileInfoMediaFileInfoFile info
libraryFolderstringLibrary folder
widthintImage width
heightintImage height
maxSideSizeintMaximum side size
Returns
- byte[]
GetImageThumbnailInternal(MediaFileInfo, string, int, int, int)
Returns image thumbnail from the disk or create a new one if doesn't exist yet.
protected virtual byte[] GetImageThumbnailInternal(MediaFileInfo fileInfo, string libraryFolder, int width, int height, int maxSideSize)
Parameters
fileInfoMediaFileInfoFile info
libraryFolderstringLibrary folder
widthintImage width
heightintImage height
maxSideSizeintMaximum side size
Returns
- byte[]
GetMediaFileInfo(int, string)
Returns the MediaFileInfo structure for the specified media file.
public static MediaFileInfo GetMediaFileInfo(int mediaLibraryId, string mediaFilePath)
Parameters
mediaLibraryIdintMedia library ID
mediaFilePathstringFile path
Returns
GetMediaFileInfo(string, string)
Returns the MediaFileInfo structure for the specified media file.
public static MediaFileInfo GetMediaFileInfo(string mediaFilePath, string libraryFolder)
Parameters
mediaFilePathstringFile path
libraryFolderstringLibrary folder name
Returns
GetMediaFileInfoInternal(Guid)
Returns media file with specified GUID.
protected virtual MediaFileInfo GetMediaFileInfoInternal(Guid guid)
Parameters
guidGuidMedia file GUID
Returns
GetMediaFileInfoInternal(int, string)
Returns the MediaFileInfo structure for the specified media file.
protected virtual MediaFileInfo GetMediaFileInfoInternal(int mediaLibraryId, string mediaFilePath)
Parameters
mediaLibraryIdintMedia library ID
mediaFilePathstringFile path
Returns
GetMediaFileInfoInternal(string, string)
Returns the MediaFileInfo structure for the specified media file.
protected virtual MediaFileInfo GetMediaFileInfoInternal(string mediaFilePath, string libraryFolder)
Parameters
mediaFilePathstringFile path
libraryFolderstringLibrary folder name
Returns
GetMediaFilePath(MediaFileInfo, string)
Returns physical path to the media file.
public static string GetMediaFilePath(MediaFileInfo fileInfo, string webFullPath)
Parameters
fileInfoMediaFileInfoMedia file info
webFullPathstringPhysical path to the root of the web project (e.g. c:\WebProject), if it is not specified web application physical path is used
Returns
- string
GetMediaFilePath(int, string)
Returns physical path to the media file.
public static string GetMediaFilePath(int libraryId, string filePath)
Parameters
libraryIdintMedia library ID
filePathstringFile path
Returns
- string
GetMediaFilePath(string, int, string)
Returns physical path to the given file path and library.
public static string GetMediaFilePath(string filePath, int fileLibraryId, string webFullPath = null)
Parameters
filePathstringMedia file path
fileLibraryIdintLibrary ID of the media file
webFullPathstringPhysical path to the root of the web project (e.g. c:\WebProject), if it is not specified web application physical path is used
Returns
- string
GetMediaFilePath(string, string, string)
Returns physical path to the media file.
public static string GetMediaFilePath(string libraryFolder, string filePath, string webFullPath = null)
Parameters
libraryFolderstringLibrary folder name
filePathstringFile path within the library folder
webFullPathstringPhysical path to the root of the web project (e.g. c:\WebProject), if it is not specified web application physical path is used
Returns
- string
GetMediaFilePathInternal(string, string, string)
Returns physical path to the media file.
protected virtual string GetMediaFilePathInternal(string libraryFolder, string filePath, string webFullPath)
Parameters
libraryFolderstringLibrary folder name
filePathstringFile path within the library folder
webFullPathstringPhysical path to the root of the web project (e.g. c:\WebProject), if it is not specified web application physical path is used
Returns
- string
GetMediaFiles(string, string, int, string)
Returns dataset of files matching given criteria from database.
public static ObjectQuery<MediaFileInfo> GetMediaFiles(string where, string orderBy = null, int topN = -1, string columns = null)
Parameters
wherestringWHERE condition
orderBystringORDER BY parameter
topNintTOP N parameter
columnsstringSelected columns
Returns
GetMediaFilesInternal()
Returns the query for all media files.
protected virtual ObjectQuery<MediaFileInfo> GetMediaFilesInternal()
Returns
GetPreviewFilePath(MediaFileInfo)
Returns preview file path for media file info. If no preview found returns NULL
public static string GetPreviewFilePath(MediaFileInfo fileInfo)
Parameters
fileInfoMediaFileInfoMedia file info
Returns
- string
GetPreviewFilePath(string, int)
Returns preview file path for search pattern (.* as extension).
public static string GetPreviewFilePath(string filePath, int libraryId)
Parameters
filePathstringFile path from database
libraryIdintLibrary ID
Returns
- string
GetPreviewFilePathInternal(string, int)
Returns preview file path for search pattern (.* as extension).
protected virtual string GetPreviewFilePathInternal(string filePath, int libraryId)
Parameters
filePathstringFile path from database
libraryIdintLibrary ID
Returns
- string
GetThumbnail(string, int, int, int, int)
Returns image thumbnail from the disk or create a new one if doesn't exist yet.
public static byte[] GetThumbnail(string originalFilePath, int originalWidth, int originalHeight, int width, int height)
Parameters
originalFilePathstringOriginal file path
originalWidthintOriginal width
originalHeightintOriginal height
widthintWidth
heightintHeight
Returns
- byte[]
GetThumbnailInternal(string, int, int, int, int)
Returns image thumbnail from the disk or create a new one if doesn't exist yet.
protected virtual byte[] GetThumbnailInternal(string originalFilePath, int originalWidth, int originalHeight, int width, int height)
Parameters
originalFilePathstringOriginal file path
originalWidthintOriginal width
originalHeightintOriginal height
widthintWidth
heightintHeight
Returns
- byte[]
GetThumbnailPath(int, string)
Returns physical path to the thumbnail folder.
public static string GetThumbnailPath(int libraryId, string filePath)
Parameters
libraryIdintMedia library ID
filePathstringFile path from database
Returns
- string
GetThumbnailPath(string, int, string)
Returns physical path to the thumbnail folder.
public static string GetThumbnailPath(string filePath, int libraryId, string webFullPath = null)
Parameters
filePathstringFile path from database
libraryIdintMedia library ID
webFullPathstringPhysical path to the root of the web project (e.g. c:\WebProject), if it is not specified web application physical path is used
Returns
- string
GetThumbnailPath(string, string, string, int, int, bool, bool)
Returns physical path to the thumbnail.
public static string GetThumbnailPath(string fileName, string fileExtension, string path, int width, int height, bool addHiddenFolder, bool addFileExtension)
Parameters
fileNamestringFile name of the file thumbnail is related to
fileExtensionstringExtension of the file thumbnail is related to
pathstringPath of the original file
widthintWidth of the thumbnail file
heightintHeight of the thumbnail file
addHiddenFolderboolIndicates if hidden folder should be inserted into path
addFileExtensionboolIndicates if file extension should be inserted into thumbnail file name
Returns
- string
GetThumbnailPathInternal(string, int, string)
Returns physical path to the thumbnail folder.
protected virtual string GetThumbnailPathInternal(string filePath, int libraryId, string webFullPath = null)
Parameters
filePathstringFile path from database
libraryIdintMedia library ID
webFullPathstringPhysical path to the root of the web project (e.g. c:\WebProject), if it is not specified web application physical path is used
Returns
- string
GetThumbnailPathInternal(string, string, string, int, int, bool, bool)
Returns physical path to the thumbnail.
protected virtual string GetThumbnailPathInternal(string fileName, string fileExtension, string path, int width, int height, bool addHiddenFolder, bool addFileExtension)
Parameters
fileNamestringFile name of the file thumbnail is related to
fileExtensionstringExtension of the file thumbnail is related to
pathstringPath of the original file
widthintWidth of the thumbnail file
heightintHeight of the thumbnail file
addHiddenFolderboolIndicates if hidden folder should be inserted into path
addFileExtensionboolIndicates if file extension should be inserted into thumbnail file name
Returns
- string
ImportMediaFileInfo(MediaFileInfo, int)
Import media file into database.
public static void ImportMediaFileInfo(MediaFileInfo mediaFile, int userId = 0)
Parameters
mediaFileMediaFileInfoMedia file to import
userIdintID of the user performing set action
ImportMediaFileInfoInternal(MediaFileInfo, int)
Import media file into database.
protected virtual void ImportMediaFileInfoInternal(MediaFileInfo mediaFile, int userId)
Parameters
mediaFileMediaFileInfoMedia file to import
userIdintID of the user performing set action
MoveMediaFile(int, int, string, string, bool)
Moves media file.
public static void MoveMediaFile(int originalLibraryID, int newLibraryID, string origPath, string newPath, bool synchronization = false)
Parameters
originalLibraryIDintOriginal library ID
newLibraryIDintNew library ID
origPathstringOld file path within the library folder
newPathstringNew file path within the library folder
synchronizationboolIndicates if method is running by web farms synchronization
MoveMediaFile(int, string, string, bool)
Moves media file within one library.
public static void MoveMediaFile(int libraryID, string origPath, string newPath, bool synchronization = false)
Parameters
libraryIDintLibrary ID
origPathstringOld file path within the library folder
newPathstringNew file path within the library folder
synchronizationboolIndicates if method is running by web farms synchronization
MoveMediaFileInternal(int, int, string, string, bool)
Moves media file.
protected virtual void MoveMediaFileInternal(int originalLibraryID, int newLibraryID, string origPath, string newPath, bool synchronization)
Parameters
originalLibraryIDintOriginal library ID
newLibraryIDintNew library ID
origPathstringOld file path within the library folder
newPathstringNew file path within the library folder
synchronizationboolIndicates if method is running by web farms synchronization
SaveFileToDisk(string, string, string, string, Guid, BinaryDataWrapper, bool, bool)
Saves media file to disk and returns the applied file path.
public static string SaveFileToDisk(string libraryFolder, string librarySubFolderPath, string fileName, string fileExtension, Guid fileGuid, BinaryDataWrapper fileData, bool synchronization, bool ensureUniqueFileName = true)
Parameters
libraryFolderstringMedia library root folder
librarySubFolderPathstringSubfolder path
fileNamestringName of the file
fileExtensionstringExtension of the file
fileGuidGuidFile GUID
fileDataBinaryDataWrapperFile data
synchronizationboolIndicates if method is running by web farms synchronization
ensureUniqueFileNameboolIndicates if unique file name should be ensured
Returns
- string
SaveFileToDiskInternal(string, string, string, string, Guid, BinaryDataWrapper, bool, bool, bool, string, string)
Saves media file to disk and returns the applied file path.
protected virtual string SaveFileToDiskInternal(string libraryFolder, string librarySubFolderPath, string fileName, string fileExtension, Guid fileGuid, BinaryDataWrapper fileData, bool synchronization, bool ensureUniqueFileName, bool skipChecks, string filePath, string fileSubFolderPath)
Parameters
libraryFolderstringMedia library root folder
librarySubFolderPathstringSubfolder path
fileNamestringName of the file
fileExtensionstringExtension of the file
fileGuidGuidFile GUID
fileDataBinaryDataWrapperFile data
synchronizationboolIndicates if method is running by web farms synchronization
ensureUniqueFileNameboolIndicates if unique file name should be ensured
skipChecksboolSkip check for file path and ensuring physical file path
filePathstringFile path
fileSubFolderPathstringFile subfolder path
Returns
- string
Set(MediaFileInfo)
Inserts or updates the info object in the underlying data store.
public override void Set(MediaFileInfo info)
Parameters
infoMediaFileInfoInfo object to be inserted or updated.
Exceptions
- ArgumentNullException
Thrown when
infois null.
- See Also
-
EnsureUniqueFileName(bool)SaveFileToDisk(bool)
ShouldResize(int, int, int, int, int)
Returns true if image should be scaled down.
public static bool ShouldResize(int maxSideSize, int width, int height, int imageWidth, int imageHeight)
Parameters
maxSideSizeintMax side size
widthintWidth
heightintHeight
imageWidthintImage width
imageHeightintImage height
Returns
- bool
ShouldResizeInternal(int, int, int, int, int)
Returns true if image should be scaled down.
protected virtual bool ShouldResizeInternal(int maxSideSize, int width, int height, int imageWidth, int imageHeight)
Parameters
maxSideSizeintMax side size
widthintWidth
heightintHeight
imageWidthintImage width
imageHeightintImage height
Returns
- bool