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. |
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. |
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. |
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. |