// (c) Copyright Ascensio System SIA 2010-2022
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
namespace ASC.Data.Storage;
///
/// Interface for working with files
///
public interface IDataStore
{
IQuotaController QuotaController { get; set; }
TimeSpan GetExpire(string domain);
///
/// Get absolute Uri for html links to handler
///
///
///
Task GetUriAsync(string path);
///
/// Get absolute Uri for html links to handler
///
///
///
///
Task GetUriAsync(string domain, string path);
///
/// Get absolute Uri for html links to handler
///
///
///
///
///
///
Task GetPreSignedUriAsync(string domain, string path, TimeSpan expire, IEnumerable headers);
///
/// Supporting generate uri to the file
///
///
bool IsSupportInternalUri { get; }
///
/// Get absolute Uri for html links
///
///
///
///
///
///
Task GetInternalUriAsync(string domain, string path, TimeSpan expire, IEnumerable headers);
///
/// A stream of read-only. In the case of the C3 stream NetworkStream general, and with him we have to work
/// Very carefully as a Jedi cutter groin lightsaber.
///
///
///
///
Task GetReadStreamAsync(string domain, string path);
///
/// A stream of read-only. In the case of the C3 stream NetworkStream general, and with him we have to work
/// Very carefully as a Jedi cutter groin lightsaber.
///
///
///
///
Task GetReadStreamAsync(string domain, string path, int offset);
///
/// Saves the contents of the stream in the repository.
/// Summary>
///
///
/// flow. Is read from the current position! Desirable to set to 0 when the transmission MemoryStream instance
///
Task SaveAsync(string domain, string path, Stream stream);
///
/// Saves the contents of the stream in the repository.
///
///
///
///
///
///
Task SaveAsync(string domain, string path, Stream stream, ACL acl);
///
/// Saves the contents of the stream in the repository.
///
///
///
///
///
///
Task SaveAsync(string domain, string path, Stream stream, string attachmentFileName);
///
/// Saves the contents of the stream in the repository.
///
///
///
///
///
///
///
Task SaveAsync(string domain, string path, Stream stream, string contentType, string contentDisposition);
///
/// Saves the contents of the stream in the repository.
///
///
///
///
///
///
///
Task SaveAsync(string domain, string path, Stream stream, string contentEncoding, int cacheDays);
Task InitiateChunkedUploadAsync(string domain, string path);
Task UploadChunkAsync(string domain, string path, string uploadId, Stream stream, long defaultChunkSize, int chunkNumber, long chunkLength);
Task FinalizeChunkedUploadAsync(string domain, string path, string uploadId, Dictionary eTags);
Task AbortChunkedUploadAsync(string domain, string path, string uploadId);
bool IsSupportChunking { get; }
bool IsSupportedPreSignedUri { get; }
///
/// Deletes file
///
///
///
Task DeleteAsync(string domain, string path);
///
/// Deletes file by mask
///
///
///
///Wildcard mask (*.png)
///
Task DeleteFilesAsync(string domain, string folderPath, string pattern, bool recursive);
///
/// Deletes files
///
///
///
Task DeleteFilesAsync(string domain, List paths);
///
/// Deletes file by last modified date
///
///
///
///
///
Task DeleteFilesAsync(string domain, string folderPath, DateTime fromDate, DateTime toDate);
///
/// Moves the contents of one directory to another. s3 for a very expensive procedure.
///
///
///
///
///
Task MoveDirectoryAsync(string srcdomain, string srcdir, string newdomain, string newdir);
///
/// Moves file
///
///
///
///
///
///
Task MoveAsync(string srcdomain, string srcpath, string newdomain, string newpath, bool quotaCheckFileSize = true);
///
/// Saves the file in the temp. In fact, almost no different from the usual Save except that generates the file name itself. An inconvenient thing.
///
///
///
///
///
Task SaveTempAsync(string domain, out string assignedPath, Stream stream);
///
/// Returns a list of links to all subfolders
///
///
///
/// iterate subdirectories or not
///
IAsyncEnumerable ListDirectoriesRelativeAsync(string domain, string path, bool recursive);
///
/// Returns a list of links to all files
///
///
///
///Wildcard mask (*. jpg for example)
///iterate subdirectories or not
///
IAsyncEnumerable ListFilesAsync(string domain, string path, string pattern, bool recursive);
///
/// Returns a list of relative paths for all files
///
///
///
///Wildcard mask (*. jpg for example)
///iterate subdirectories or not
///
IAsyncEnumerable ListFilesRelativeAsync(string domain, string path, string pattern, bool recursive);
///
/// Checks whether a file exists. On s3 it took long time.
///
///
///
///
Task IsFileAsync(string domain, string path);
///
/// Checks whether a directory exists. On s3 it took long time.
///
///
///
///
Task IsDirectoryAsync(string domain, string path);
Task DeleteDirectoryAsync(string domain, string path);
Task GetFileSizeAsync(string domain, string path);
Task GetDirectorySizeAsync(string domain, string path);
Task ResetQuotaAsync(string domain);
Task GetUsedQuotaAsync(string domain);
Task CopyAsync(string srcdomain, string path, string newdomain, string newpath);
Task CopyDirectoryAsync(string srcdomain, string dir, string newdomain, string newdir);
//Then there are restarted methods without domain. functionally identical to the top
#pragma warning disable 1591
Task GetReadStreamAsync(string path);
Task SaveAsync(string path, Stream stream, string attachmentFileName);
Task SaveAsync(string path, Stream stream);
Task DeleteAsync(string path);
Task DeleteFilesAsync(string folderPath, string pattern, bool recursive);
Task MoveAsync(string srcpath, string newdomain, string newpath);
Task SaveTempAsync(out string assignedPath, Stream stream);
IAsyncEnumerable ListDirectoriesRelativeAsync(string path, bool recursive);
IAsyncEnumerable ListFilesAsync(string path, string pattern, bool recursive);
Task IsFileAsync(string path);
Task IsDirectoryAsync(string path);
Task DeleteDirectoryAsync(string path);
Task GetFileSizeAsync(string path);
Task GetDirectorySizeAsync(string path);
Task CopyAsync(string path, string newdomain, string newpath);
Task CopyDirectoryAsync(string dir, string newdomain, string newdir);
#pragma warning restore 1591
IDataStore Configure(string tenant, Handler handlerConfig, Module moduleConfig, IDictionary props);
IDataStore SetQuotaController(IQuotaController controller);
Task SavePrivateAsync(string domain, string path, Stream stream, DateTime expires);
Task DeleteExpiredAsync(string domain, string path, TimeSpan oldThreshold);
string GetUploadForm(string domain, string directoryPath, string redirectTo, long maxUploadSize,
string contentType, string contentDisposition, string submitLabel);
Task GetUploadedUrlAsync(string domain, string directoryPath);
string GetUploadUrl();
string GetPostParams(string domain, string directoryPath, long maxUploadSize, string contentType,
string contentDisposition);
}