Interface IMediaFileSystem
Provides methods allowing the manipulation of media files.
Namespace: Umbraco.Core.IO
Assembly: Umbraco.Core.dll
Syntax
public interface IMediaFileSystem : IFileSystem
Methods
View SourceCopyFile(IContentBase, PropertyType, String)
Copies a media file as a new media file, associated to a property of a content item.
Declaration
string CopyFile(IContentBase content, PropertyType propertyType, string sourcepath)
Parameters
Type | Name | Description |
---|---|---|
IContentBase | content | The content item owning the copy of the media file. |
PropertyType | propertyType | The property type owning the copy of the media file. |
System.String | sourcepath | The filesystem-relative path to the source media file. |
Returns
Type | Description |
---|---|
System.String | The filesystem-relative path to the copy of the media file. |
DeleteMediaFiles(IEnumerable<String>)
Delete media files.
Declaration
void DeleteMediaFiles(IEnumerable<string> files)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.IEnumerable<System.String> | files | Files to delete (filesystem-relative paths). |
GetMediaPath(String, Guid, Guid)
Gets the file path of a media file.
Declaration
string GetMediaPath(string filename, Guid cuid, Guid puid)
Parameters
Type | Name | Description |
---|---|---|
System.String | filename | The file name. |
System.Guid | cuid | The unique identifier of the content/media owning the file. |
System.Guid | puid | The unique identifier of the property type owning the file. |
Returns
Type | Description |
---|---|
System.String | The filesystem-relative path to the media file. |
Remarks
With the old media path scheme, this CREATES a new media path each time it is invoked.
GetMediaPath(String, String, Guid, Guid)
Gets the file path of a media file.
Declaration
string GetMediaPath(string filename, string prevpath, Guid cuid, Guid puid)
Parameters
Type | Name | Description |
---|---|---|
System.String | filename | The file name. |
System.String | prevpath | A previous file path. |
System.Guid | cuid | The unique identifier of the content/media owning the file. |
System.Guid | puid | The unique identifier of the property type owning the file. |
Returns
Type | Description |
---|---|
System.String | The filesystem-relative path to the media file. |
Remarks
In the old, legacy, number-based scheme, we try to re-use the media folder
specified by prevpath
. Else, we CREATE a new one. Each time we are invoked.
StoreFile(IContentBase, PropertyType, String, Stream, String)
Stores a media file associated to a property of a content item.
Declaration
string StoreFile(IContentBase content, PropertyType propertyType, string filename, Stream filestream, string oldpath)
Parameters
Type | Name | Description |
---|---|---|
IContentBase | content | The content item owning the media file. |
PropertyType | propertyType | The property type owning the media file. |
System.String | filename | The media file name. |
System.IO.Stream | filestream | A stream containing the media bytes. |
System.String | oldpath | An optional filesystem-relative filepath to the previous media file. |
Returns
Type | Description |
---|---|
System.String | The filesystem-relative filepath to the media file. |
Remarks
The file is considered "owned" by the content/propertyType.
If an oldpath
is provided then that file (and associated thumbnails if any) is deleted
before the new file is saved, and depending on the media path scheme, the folder may be reused for the new file.