Interface IMediaService
Defines the interface for a service that manages media files (e.g. images, documents).
Namespace: DataWeb.Media
Assembly: DataWeb.Core.dll
Syntax
public interface IMediaService
Methods
BytesToString(long)
Converts a byte count to a human-readable string representation.
Declaration
string BytesToString(long byteCount)
Parameters
Type | Name | Description |
---|---|---|
long | byteCount | The byte count to convert. |
Returns
Type | Description |
---|---|
string | A human-readable string representation of the byte count. |
GetAppActualSize()
Gets the actual size of the application in bytes.
Declaration
long GetAppActualSize()
Returns
Type | Description |
---|---|
long | The actual size of the application in bytes. |
GetAppMaxSize()
Gets the maximum upload file size for the application in bytes.
Declaration
long GetAppMaxSize()
Returns
Type | Description |
---|---|
long | The maximum upload file size for the application in bytes. |
GetDefaultUploadMaxFileSize()
Gets the default maximum upload file size in bytes.
Declaration
long GetDefaultUploadMaxFileSize()
Returns
Type | Description |
---|---|
long | The default maximum upload file size in bytes. |
GetDocumentUrl(string, string, object)
Gets the URL for the specified document file.
Declaration
string GetDocumentUrl(string routeName, string code, object routeValues = null)
Parameters
Type | Name | Description |
---|---|---|
string | routeName | The name of the document route. |
string | code | The unique code for the document file. |
object | routeValues | Optional route values to include in the URL. |
Returns
Type | Description |
---|---|
string | The URL for the specified document file. |
GetFile(FileData)
Gets a File object from a FileData object.
Declaration
File GetFile(FileData fileData)
Parameters
Type | Name | Description |
---|---|---|
FileData | fileData | The FileData object to use to create the File object. |
Returns
Type | Description |
---|---|
File | A File object representing the given FileData object. |
GetFileByCodeAsync(string, string, string, string, PublishMode?)
Gets a file by its code, with optional filters.
Declaration
Task<File> GetFileByCodeAsync(string code, string tagName = null, string versionName = null, string versionCulture = null, PublishMode? publishMode = null)
Parameters
Type | Name | Description |
---|---|---|
string | code | The code of the file to retrieve. |
string | tagName | The tag name of the file to retrieve. If null, the most recent tag is used. |
string | versionName | The version name of the file to retrieve. If null, the most recent version is used. |
string | versionCulture | The culture of the file to retrieve. If null, the default culture is used. |
PublishMode? | publishMode | The PublishMode of the file to retrieve. If null, the latest published version is used. |
Returns
Type | Description |
---|---|
Task<File> | A File object representing the retrieved file. |
GetFileByIdMasterAsync(string, string, string, string, PublishMode?)
Gets a file by its IdMaster, with optional filters.
Declaration
Task<File> GetFileByIdMasterAsync(string IdMaster, string tagName = null, string versionName = null, string versionCulture = null, PublishMode? publishMode = null)
Parameters
Type | Name | Description |
---|---|---|
string | IdMaster | The IdMaster of the file to retrieve. |
string | tagName | The tag name of the file to retrieve. If null, the most recent tag is used. |
string | versionName | The version name of the file to retrieve. If null, the most recent version is used. |
string | versionCulture | The culture of the file to retrieve. If null, the default culture is used. |
PublishMode? | publishMode | The PublishMode of the file to retrieve. If null, the latest published version is used. |
Returns
Type | Description |
---|---|
Task<File> | A File object representing the retrieved file. |
GetImageUrl(string, string, int, int, ResizeMode, object)
Gets the URL for the specified image file.
Declaration
string GetImageUrl(string routeName, string code, int width, int height, ResizeMode mode = ResizeMode.Fix, object routeValues = null)
Parameters
Type | Name | Description |
---|---|---|
string | routeName | The name of the image route. |
string | code | The unique code for the image file. |
int | width | The desired width of the image. |
int | height | The desired height of the image. |
ResizeMode | mode | The ResizeMode to use. |
object | routeValues | Optional route values to include in the URL. |
Returns
Type | Description |
---|---|
string | The URL for the specified image file. |
GetMimeTypeByExtension(string)
Gets the MIME type for the specified file extension.
Declaration
string GetMimeTypeByExtension(string extension)
Parameters
Type | Name | Description |
---|---|---|
string | extension | The file extension. |
Returns
Type | Description |
---|---|
string | The MIME type string. |
GetNewFileCode()
Generates a new file code.
Declaration
string GetNewFileCode()
Returns
Type | Description |
---|---|
string | A new file code. |
GetObsoleteFiles()
Gets a list of obsolete files (files that are no longer used).
Declaration
Task<IEnumerable<File>> GetObsoleteFiles()
Returns
Type | Description |
---|---|
Task<IEnumerable<File>> | An IEnumerable of File objects representing the obsolete files. |
SanitizeFileName(string)
Sanitizes a file name, removing invalid characters.
Declaration
string SanitizeFileName(string fileName)
Parameters
Type | Name | Description |
---|---|---|
string | fileName | The file name to sanitize. |
Returns
Type | Description |
---|---|
string | The sanitized file name. |
UpdateIsInStorage(string, bool)
Updates the IsInStorage flag of a file.
Declaration
Task UpdateIsInStorage(string fileIdMaster, bool isInStorage)
Parameters
Type | Name | Description |
---|---|---|
string | fileIdMaster | The IdMaster of the file to update. |
bool | isInStorage | The new value of the IsInStorage flag. |
Returns
Type | Description |
---|---|
Task |
UploadChunkStreamAsync(string, Stream, int, int, int, long, string, string, string)
Uploads a chunk of a file stream to a storage provider.
Declaration
Task<SaveUploadStreamResult> UploadChunkStreamAsync(string storageName, Stream stream, int chunkNumber, int chunkSize, int chunkCount, long fileSize, string fileId, string fileExtension, string storageContainer)
Parameters
Type | Name | Description |
---|---|---|
string | storageName | The name of the storage provider. |
Stream | stream | The file stream to upload. |
int | chunkNumber | The current chunk number. |
int | chunkSize | The size of each chunk in bytes. |
int | chunkCount | The total number of chunks. |
long | fileSize | The size of the file being uploaded. |
string | fileId | The unique Id of the file. |
string | fileExtension | The file extension. |
string | storageContainer | The name of the storage container. |
Returns
Type | Description |
---|---|
Task<SaveUploadStreamResult> | A SaveUploadStreamResult object containing the result of the upload operation. |