Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make default media file store methods virtual #8006

Merged
merged 1 commit into from
Dec 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions src/OrchardCore/OrchardCore.Media.Core/DefaultMediaFileStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,27 +40,27 @@ ILogger<DefaultMediaFileStore> logger
_logger = logger;
}

public Task<IFileStoreEntry> GetFileInfoAsync(string path)
public virtual Task<IFileStoreEntry> GetFileInfoAsync(string path)
{
return _fileStore.GetFileInfoAsync(path);
}

public Task<IFileStoreEntry> GetDirectoryInfoAsync(string path)
public virtual Task<IFileStoreEntry> GetDirectoryInfoAsync(string path)
{
return _fileStore.GetDirectoryInfoAsync(path);
}

public Task<IEnumerable<IFileStoreEntry>> GetDirectoryContentAsync(string path = null, bool includeSubDirectories = false)
public virtual Task<IEnumerable<IFileStoreEntry>> GetDirectoryContentAsync(string path = null, bool includeSubDirectories = false)
{
return _fileStore.GetDirectoryContentAsync(path, includeSubDirectories);
}

public Task<bool> TryCreateDirectoryAsync(string path)
public virtual Task<bool> TryCreateDirectoryAsync(string path)
{
return _fileStore.TryCreateDirectoryAsync(path);
}

public async Task<bool> TryDeleteFileAsync(string path)
public virtual async Task<bool> TryDeleteFileAsync(string path)
{
var deletingContext = new MediaDeletingContext
{
Expand All @@ -82,7 +82,7 @@ public async Task<bool> TryDeleteFileAsync(string path)
return result;
}

public async Task<bool> TryDeleteDirectoryAsync(string path)
public virtual async Task<bool> TryDeleteDirectoryAsync(string path)
{
var deletingContext = new MediaDeletingContext
{
Expand All @@ -104,7 +104,7 @@ public async Task<bool> TryDeleteDirectoryAsync(string path)
return result;
}

public async Task MoveFileAsync(string oldPath, string newPath)
public virtual async Task MoveFileAsync(string oldPath, string newPath)
{
var context = new MediaMoveContext
{
Expand All @@ -119,22 +119,22 @@ public async Task MoveFileAsync(string oldPath, string newPath)
await _mediaEventHandlers.InvokeAsync((handler, context) => handler.MediaMovedAsync(context), context, _logger);
}

public Task CopyFileAsync(string srcPath, string dstPath)
public virtual Task CopyFileAsync(string srcPath, string dstPath)
{
return _fileStore.CopyFileAsync(srcPath, dstPath);
}

public Task<Stream> GetFileStreamAsync(string path)
public virtual Task<Stream> GetFileStreamAsync(string path)
{
return _fileStore.GetFileStreamAsync(path);
}

public Task<Stream> GetFileStreamAsync(IFileStoreEntry fileStoreEntry)
public virtual Task<Stream> GetFileStreamAsync(IFileStoreEntry fileStoreEntry)
{
return _fileStore.GetFileStreamAsync(fileStoreEntry);
}

public async Task<string> CreateFileFromStreamAsync(string path, Stream inputStream, bool overwrite = false)
public virtual async Task<string> CreateFileFromStreamAsync(string path, Stream inputStream, bool overwrite = false)
{
if (_mediaCreatingEventHandlers.Any())
{
Expand Down Expand Up @@ -176,7 +176,7 @@ public async Task<string> CreateFileFromStreamAsync(string path, Stream inputStr
}
}

public string MapPathToPublicUrl(string path)
public virtual string MapPathToPublicUrl(string path)
{
return _cdnBaseUrl + _requestBasePath + "/" + _fileStore.NormalizePath(path);
}
Expand Down