Ilya Oleshko
ab472b0148
# Conflicts: # .gitignore # build/install/docker/Dockerfile.dev # build/install/docker/build.dev.yml # build/install/docker/docspace.dev.yml # build/install/win/DocSpace.aip # common/ASC.ActiveDirectory/Base/DbHelper.cs # common/ASC.Api.Core/Model/EmployeeDto.cs # common/ASC.Core.Common/Billing/ITariffService.cs # common/ASC.Core.Common/Billing/License/LicenseReader.cs # common/ASC.Core.Common/Billing/TariffService.cs # common/ASC.Core.Common/Context/Impl/CoreConfiguration.cs # common/ASC.Core.Common/Context/Impl/UserManager.cs # common/ASC.Core.Common/HostedSolution.cs # common/ASC.Core.Common/Messaging/MessagesContext.cs # common/ASC.Core.Common/Tenants/TenantCookieSettings.cs # common/ASC.Data.Storage/GoogleCloud/GoogleCloudStorage.cs # common/ASC.Data.Storage/IQuotaController.cs # common/ASC.Data.Storage/RackspaceCloud/RackspaceCloudStorage.cs # common/ASC.Data.Storage/S3/S3Storage.cs # common/Tools/ASC.Migration.Creator/ASC.Migration.Creator.csproj # common/Tools/ASC.Migration.Runner/ASC.Migration.Runner.csproj # common/Tools/ASC.Migration.Runner/GlobalUsings.cs # common/Tools/ASC.Migration.Runner/MigrationRunner.cs # common/Tools/ASC.Migration.Runner/Program.cs # common/Tools/ASC.MigrationPersonalToDocspace/MigrationRunner.cs # common/Tools/ASC.Migrations.Core/Models/ConfigurationInfo.cs # common/Tools/ASC.Migrations.Core/Utils/DbContextActivator.cs # common/services/ASC.ClearEvents/Services/ClearEventsService.cs # common/services/ASC.ElasticSearch/Core/SearchSettings.cs # common/services/ASC.ElasticSearch/Engine/FactoryIndexer.cs # config/nginx/onlyoffice.conf # migrations/mysql/ASC.Migrations.MySql.csproj # migrations/mysql/SaaS/AccountLinkContext/20221019144349_AccountLinkContextMigrate.Designer.cs # migrations/mysql/SaaS/AccountLinkContext/20221019144349_AccountLinkContextMigrate.cs # migrations/mysql/SaaS/AccountLinkContext/AccountLinkContextModelSnapshot.cs # migrations/mysql/SaaS/BackupsContext/20230130103901_BackupsContextMigrate.Designer.cs # migrations/mysql/SaaS/BackupsContext/20230130103901_BackupsContextMigrate.cs # migrations/mysql/SaaS/BackupsContext/BackupsContextModelSnapshot.cs # migrations/mysql/SaaS/CoreDbContext/20230130103905_CoreDbContextMigrate.Designer.cs # migrations/mysql/SaaS/CoreDbContext/20230130103905_CoreDbContextMigrate.cs # migrations/mysql/SaaS/CoreDbContext/CoreDbContextModelSnapshot.cs # migrations/mysql/SaaS/CustomDbContext/20221019144350_CustomDbContextMigrate.Designer.cs # migrations/mysql/SaaS/CustomDbContext/20221019144350_CustomDbContextMigrate.cs # migrations/mysql/SaaS/CustomDbContext/CustomDbContextModelSnapshot.cs # migrations/mysql/SaaS/FeedDbContext/20221019144344_FeedDbContextMigrate.Designer.cs # migrations/mysql/SaaS/FeedDbContext/20221019144344_FeedDbContextMigrate.cs # migrations/mysql/SaaS/FeedDbContext/FeedDbContextModelSnapshot.cs # migrations/mysql/SaaS/FilesDbContext/20230130103904_FilesDbContextMigrate.Designer.cs # migrations/mysql/SaaS/FilesDbContext/20230130103904_FilesDbContextMigrate.cs # migrations/mysql/SaaS/FilesDbContext/20230515174318_FilesDbContext_Upgrade1.Designer.cs # migrations/mysql/SaaS/FilesDbContext/20230515174318_FilesDbContext_Upgrade1.cs # migrations/mysql/SaaS/FilesDbContext/FilesDbContextModelSnapshot.cs # migrations/mysql/SaaS/FirebaseDbContext/20221019144351_FirebaseDbContextMigrate.Designer.cs # migrations/mysql/SaaS/FirebaseDbContext/20221019144351_FirebaseDbContextMigrate.cs # migrations/mysql/SaaS/FirebaseDbContext/FirebaseDbContextModelSnapshot.cs # migrations/mysql/SaaS/InstanceRegistrationContext/20221019144346_InstanceRegistrationContextMigrate.Designer.cs # migrations/mysql/SaaS/InstanceRegistrationContext/20221019144346_InstanceRegistrationContextMigrate.cs # migrations/mysql/SaaS/InstanceRegistrationContext/InstanceRegistrationContextModelSnapshot.cs # migrations/mysql/SaaS/IntegrationEventLogContext/20221019144342_IntegrationEventLogContextMigrate.Designer.cs # migrations/mysql/SaaS/IntegrationEventLogContext/20221019144342_IntegrationEventLogContextMigrate.cs # migrations/mysql/SaaS/IntegrationEventLogContext/IntegrationEventLogContextModelSnapshot.cs # migrations/mysql/SaaS/MessagesContext/20221019144345_MessagesContextMigrate.Designer.cs # migrations/mysql/SaaS/MessagesContext/20221019144345_MessagesContextMigrate.cs # migrations/mysql/SaaS/MessagesContext/MessagesContextModelSnapshot.cs # migrations/mysql/SaaS/NotifyDbContext/20221019144352_NotifyDbContextMigrate.Designer.cs # migrations/mysql/SaaS/NotifyDbContext/20221019144352_NotifyDbContextMigrate.cs # migrations/mysql/SaaS/NotifyDbContext/NotifyDbContextModelSnapshot.cs # migrations/mysql/SaaS/TeamlabSiteContext/20221219145514_TeamlabSiteContextMigrate.Designer.cs # migrations/mysql/SaaS/TeamlabSiteContext/20221219145514_TeamlabSiteContextMigrate.cs # migrations/mysql/SaaS/TeamlabSiteContext/20230621121634_TeamlabSiteContextMigrate.Designer.cs # migrations/mysql/SaaS/TeamlabSiteContext/20230621121634_TeamlabSiteContextMigrate.cs # migrations/mysql/SaaS/TelegramDbContext/20221019144353_TelegramDbContextMigrate.Designer.cs # migrations/mysql/SaaS/TelegramDbContext/20221019144353_TelegramDbContextMigrate.cs # migrations/mysql/SaaS/TelegramDbContext/TelegramDbContextModelSnapshot.cs # migrations/mysql/SaaS/TenantDbContext/20221019144354_TenantDbContextMigrate.Designer.cs # migrations/mysql/SaaS/TenantDbContext/20221019144354_TenantDbContextMigrate.cs # migrations/mysql/SaaS/TenantDbContext/TenantDbContextModelSnapshot.cs # migrations/mysql/SaaS/UrlShortenerFakeDbContext/20221019144355_UrlShortenerFakeDbContextMigrate.Designer.cs # migrations/mysql/SaaS/UrlShortenerFakeDbContext/20221019144355_UrlShortenerFakeDbContextMigrate.cs # migrations/mysql/SaaS/UrlShortenerFakeDbContext/UrlShortenerFakeDbContextModelSnapshot.cs # migrations/mysql/SaaS/UserDbContext/20230310195637_UserDbContextMigrate.Designer.cs # migrations/mysql/SaaS/UserDbContext/20230310195637_UserDbContextMigrate.cs # migrations/mysql/SaaS/UserDbContext/UserDbContextModelSnapshot.cs # migrations/mysql/SaaS/WebhooksDbContext/20221019144343_WebhooksDbContextMigrate.Designer.cs # migrations/mysql/SaaS/WebhooksDbContext/20221019144343_WebhooksDbContextMigrate.cs # migrations/mysql/SaaS/WebhooksDbContext/WebhooksDbContextModelSnapshot.cs # migrations/mysql/SaaS/WebstudioDbContext/20221019144356_WebstudioDbContextMigrate.Designer.cs # migrations/mysql/SaaS/WebstudioDbContext/20221019144356_WebstudioDbContextMigrate.cs # migrations/mysql/SaaS/WebstudioDbContext/WebstudioDbContextModelSnapshot.cs # migrations/mysql/TeamlabSiteContext/20221219145514_TeamlabSiteContextMigrate.Designer.cs # migrations/mysql/TeamlabSiteContext/20221219145514_TeamlabSiteContextMigrate.cs # migrations/postgre/ASC.Migrations.PostgreSql.csproj # migrations/postgre/SaaS/AccountLinkContext/20221019144350_AccountLinkContextMigrate.Designer.cs # migrations/postgre/SaaS/AccountLinkContext/20221019144350_AccountLinkContextMigrate.cs # migrations/postgre/SaaS/AccountLinkContext/AccountLinkContextModelSnapshot.cs # migrations/postgre/SaaS/BackupsContext/20230130103902_BackupsContextMigrate.Designer.cs # migrations/postgre/SaaS/BackupsContext/20230130103902_BackupsContextMigrate.cs # migrations/postgre/SaaS/BackupsContext/BackupsContextModelSnapshot.cs # migrations/postgre/SaaS/CoreDbContext/20230130103905_CoreDbContextMigrate.Designer.cs # migrations/postgre/SaaS/CoreDbContext/20230130103905_CoreDbContextMigrate.cs # migrations/postgre/SaaS/CoreDbContext/CoreDbContextModelSnapshot.cs # migrations/postgre/SaaS/CustomDbContext/20221019144351_CustomDbContextMigrate.Designer.cs # migrations/postgre/SaaS/CustomDbContext/20221019144351_CustomDbContextMigrate.cs # migrations/postgre/SaaS/CustomDbContext/CustomDbContextModelSnapshot.cs # migrations/postgre/SaaS/FeedDbContext/20221019144345_FeedDbContextMigrate.Designer.cs # migrations/postgre/SaaS/FeedDbContext/20221019144345_FeedDbContextMigrate.cs # migrations/postgre/SaaS/FeedDbContext/FeedDbContextModelSnapshot.cs # migrations/postgre/SaaS/FilesDbContext/20230130103904_FilesDbContextMigrate.Designer.cs # migrations/postgre/SaaS/FilesDbContext/20230130103904_FilesDbContextMigrate.cs # migrations/postgre/SaaS/FilesDbContext/20230515174319_FilesDbContext_Upgrade1.Designer.cs # migrations/postgre/SaaS/FilesDbContext/20230515174319_FilesDbContext_Upgrade1.cs # migrations/postgre/SaaS/FilesDbContext/FilesDbContextModelSnapshot.cs # migrations/postgre/SaaS/FirebaseDbContext/20221019144352_FirebaseDbContextMigrate.Designer.cs # migrations/postgre/SaaS/FirebaseDbContext/20221019144352_FirebaseDbContextMigrate.cs # migrations/postgre/SaaS/FirebaseDbContext/FirebaseDbContextModelSnapshot.cs # migrations/postgre/SaaS/InstanceRegistrationContext/20221019144347_InstanceRegistrationContextMigrate.Designer.cs # migrations/postgre/SaaS/InstanceRegistrationContext/20221019144347_InstanceRegistrationContextMigrate.cs # migrations/postgre/SaaS/InstanceRegistrationContext/InstanceRegistrationContextModelSnapshot.cs # migrations/postgre/SaaS/IntegrationEventLogContext/20221019144343_IntegrationEventLogContextMigrate.Designer.cs # migrations/postgre/SaaS/IntegrationEventLogContext/20221019144343_IntegrationEventLogContextMigrate.cs # migrations/postgre/SaaS/IntegrationEventLogContext/IntegrationEventLogContextModelSnapshot.cs # migrations/postgre/SaaS/MessagesContext/20221019144346_MessagesContextMigrate.Designer.cs # migrations/postgre/SaaS/MessagesContext/20221019144346_MessagesContextMigrate.cs # migrations/postgre/SaaS/MessagesContext/MessagesContextModelSnapshot.cs # migrations/postgre/SaaS/NotifyDbContext/20221019144353_NotifyDbContextMigrate.Designer.cs # migrations/postgre/SaaS/NotifyDbContext/20221019144353_NotifyDbContextMigrate.cs # migrations/postgre/SaaS/NotifyDbContext/NotifyDbContextModelSnapshot.cs # migrations/postgre/SaaS/TelegramDbContext/20221019144354_TelegramDbContextMigrate.Designer.cs # migrations/postgre/SaaS/TelegramDbContext/20221019144354_TelegramDbContextMigrate.cs # migrations/postgre/SaaS/TelegramDbContext/TelegramDbContextModelSnapshot.cs # migrations/postgre/SaaS/TenantDbContext/20221019144355_TenantDbContextMigrate.Designer.cs # migrations/postgre/SaaS/TenantDbContext/20221019144355_TenantDbContextMigrate.cs # migrations/postgre/SaaS/TenantDbContext/TenantDbContextModelSnapshot.cs # migrations/postgre/SaaS/UrlShortenerFakeDbContext/20221019144356_UrlShortenerFakeDbContextMigrate.Designer.cs # migrations/postgre/SaaS/UrlShortenerFakeDbContext/20221019144356_UrlShortenerFakeDbContextMigrate.cs # migrations/postgre/SaaS/UrlShortenerFakeDbContext/UrlShortenerFakeDbContextModelSnapshot.cs # migrations/postgre/SaaS/UserDbContext/20230310195637_UserDbContextMigrate.Designer.cs # migrations/postgre/SaaS/UserDbContext/20230310195637_UserDbContextMigrate.cs # migrations/postgre/SaaS/UserDbContext/UserDbContextModelSnapshot.cs # migrations/postgre/SaaS/WebhooksDbContext/20221019144344_WebhooksDbContextMigrate.Designer.cs # migrations/postgre/SaaS/WebhooksDbContext/20221019144344_WebhooksDbContextMigrate.cs # migrations/postgre/SaaS/WebhooksDbContext/WebhooksDbContextModelSnapshot.cs # migrations/postgre/SaaS/WebstudioDbContext/20221019144357_WebstudioDbContextMigrate.Designer.cs # migrations/postgre/SaaS/WebstudioDbContext/20221019144357_WebstudioDbContextMigrate.cs # migrations/postgre/SaaS/WebstudioDbContext/WebstudioDbContextModelSnapshot.cs # packages/client/src/Shell.jsx # packages/client/src/components/Article/Body/Items.js # packages/client/src/components/Article/Body/index.js # packages/client/src/components/EmptyContainer/RoomNoAccessContainer.js # packages/client/src/components/EmptyContainer/RootFolderContainer.js # packages/client/src/components/panels/InvitePanel/index.js # packages/client/src/components/panels/InvitePanel/sub-components/AccessSelector.js # packages/client/src/components/panels/InvitePanel/sub-components/Item.js # packages/client/src/components/panels/InvitePanel/sub-components/ItemsList.js # packages/client/src/components/panels/SelectFileDialog/AsideView.js # packages/client/src/components/panels/SelectFileDialog/index.js # packages/client/src/components/panels/SelectFolderDialog/index.js # packages/client/src/components/panels/SelectionPanel/ExceptionFoldersConstants.js # packages/client/src/components/panels/SelectionPanel/SelectionPanelBody.js # packages/client/src/components/panels/SelectionPanel/StyledSelectionPanel.js # packages/client/src/pages/Accounts.jsx # packages/client/src/pages/AccountsHome/index.js # packages/client/src/pages/Confirm/index.js # packages/client/src/pages/Confirm/sub-components/removePortal.js # packages/client/src/pages/Errors/520/index.js # packages/client/src/pages/Files.jsx # packages/client/src/pages/Home/Section/AccountsBody/TableView/TableContainer.js # packages/client/src/pages/Home/Section/AccountsBody/TableView/TableRow.js # packages/client/src/pages/Home/Section/Body/TableView/TableHeader.js # packages/client/src/pages/Home/Section/Filter/index.js # packages/client/src/pages/Home/Section/Header/index.js # packages/client/src/pages/Home/Section/SettingsBody/index.js # packages/client/src/pages/Home/index.js # packages/client/src/pages/PortalSettings/Layout/Article/Body/index.js # packages/client/src/pages/PortalSettings/Layout/Section/Header/index.js # packages/client/src/pages/PortalSettings/categories/common/Customization/dns-settings.js # packages/client/src/pages/PortalSettings/categories/common/sub-components/common-tooltips.js # packages/client/src/pages/PortalSettings/categories/data-management/backup/index.js # packages/client/src/pages/PortalSettings/categories/data-management/index.js # packages/client/src/pages/PortalSettings/categories/developer-tools/JavascriptSDK/index.js # packages/client/src/pages/PortalSettings/categories/developer-tools/index.js # packages/client/src/pages/PortalSettings/categories/integration/SingleSignOn/FieldMapping.js # packages/client/src/pages/PortalSettings/categories/integration/SingleSignOn/IdpSettings.js # packages/client/src/pages/PortalSettings/categories/integration/SingleSignOn/ProviderMetadata.js # packages/client/src/pages/PortalSettings/categories/integration/SingleSignOn/sub-components/MetadataUrlField.js # packages/client/src/pages/PortalSettings/categories/payments/index.js # packages/client/src/pages/PortalSettings/categories/security/access-portal/index.js # packages/client/src/pages/PortalSettings/categories/security/access-portal/mobileView.js # packages/client/src/pages/PortalSettings/categories/security/access-portal/sessionLifetime.js # packages/client/src/pages/PortalSettings/categories/security/sub-components/category-wrapper.js # packages/client/src/pages/PortalSettings/index.js # packages/client/src/pages/PortalSettings/utils/settingsTree.js # packages/client/src/pages/Profile/Section/Body/sub-components/interface-theme/index.js # packages/client/src/pages/Profile/Section/Body/sub-components/main-profile/index.js # packages/client/src/pages/VersionHistory/Section/Body/StyledVersionHistory.js # packages/client/src/pages/VersionHistory/Section/Body/VersionRow.js # packages/client/src/pages/Wizard/index.js # packages/client/src/store/AccountsContextOptionsStore.js # packages/client/src/store/FilesActionsStore.js # packages/client/src/store/FilesStore.js # packages/common/components/Article/index.js # packages/common/components/Article/sub-components/article-alerts.js # packages/common/components/Article/sub-components/article-header.js # packages/common/components/FilterInput/sub-components/FilterBlock.js # packages/common/components/Loaders/index.js # packages/common/components/MediaViewer/sub-components/ImageViewer/ImageViewer.props.ts # packages/common/components/MediaViewer/sub-components/ImageViewer/index.tsx # packages/common/components/PrivateRoute/index.js # packages/common/store/SettingsStore.js # packages/common/store/UserStore.js # packages/common/utils/index.ts # packages/components/file-input/index.js # packages/components/selector/StyledSelector.js # packages/components/selector/index.tsx # packages/components/selector/sub-components/Body/index.tsx # packages/components/slider/styled-slider.js # products/ASC.Files/Core/Core/Dao/TeamlabDao/FileDao.cs # products/ASC.Files/Core/Core/Dao/TeamlabDao/FolderDao.cs # products/ASC.Files/Core/Core/Dao/TeamlabDao/SecurityDao.cs # products/ASC.Files/Core/Core/Security/FileSecurity.cs # products/ASC.Files/Core/Core/Thirdparty/Box/BoxFileDao.cs # products/ASC.Files/Core/Core/Thirdparty/Box/BoxFolderDao.cs # products/ASC.Files/Core/Core/Thirdparty/Dropbox/DropboxFileDao.cs # products/ASC.Files/Core/Core/Thirdparty/Dropbox/DropboxFolderDao.cs # products/ASC.Files/Core/Core/Thirdparty/GoogleDrive/GoogleDriveFileDao.cs # products/ASC.Files/Core/Core/Thirdparty/GoogleDrive/GoogleDriveFolderDao.cs # products/ASC.Files/Core/Core/Thirdparty/OneDrive/OneDriveFileDao.cs # products/ASC.Files/Core/Core/Thirdparty/OneDrive/OneDriveFolderDao.cs # products/ASC.Files/Core/Core/Thirdparty/SharePoint/SharePointFolderDao.cs # products/ASC.Files/Core/Core/Thirdparty/Sharpbox/SharpBoxFolderDao.cs # products/ASC.Files/Core/Core/Thirdparty/ThirdPartyProviderDao.cs # products/ASC.Files/Core/HttpHandlers/ChunkedUploaderHandler.cs # products/ASC.Files/Core/Utils/EntryManager.cs # products/ASC.Files/Core/Utils/FileConverter.cs # products/ASC.Files/Server/Api/FoldersController.cs # products/ASC.Files/Server/Api/SettingsController.cs # products/ASC.Files/Service/Cleanup/Worker.cs # products/ASC.People/Server/Api/UserController.cs # public/scripts/api.js # web/ASC.Web.Api/Api/AuthenticationController.cs # web/ASC.Web.Api/Api/PaymentsController.cs # web/ASC.Web.Api/Api/PortalController.cs # web/ASC.Web.Api/Api/Settings/LicenseController.cs # web/ASC.Web.Api/Api/Settings/MessageSettingsController.cs # web/ASC.Web.Api/Api/Settings/SettingsController.cs # web/ASC.Web.Api/Api/Settings/TfaappController.cs # web/ASC.Web.Api/Api/SmtpSettingsController.cs # web/ASC.Web.Api/Core/SmtpOperation.cs # web/ASC.Web.Core/CookiesManager.cs # yarn.lock
397 lines
16 KiB
C#
397 lines
16 KiB
C#
// (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;
|
|
|
|
public abstract class BaseStorage : IDataStore
|
|
{
|
|
public IQuotaController QuotaController { get; set; }
|
|
public virtual bool IsSupportInternalUri => true;
|
|
public virtual bool IsSupportCdnUri => false;
|
|
public virtual bool IsSupportedPreSignedUri => true;
|
|
public virtual bool IsSupportChunking => false;
|
|
internal string Modulename { get; set; }
|
|
internal bool Cache { get; set; }
|
|
internal DataList DataList { get; set; }
|
|
internal string Tenant { get; set; }
|
|
internal Dictionary<string, TimeSpan> DomainsExpires { get; set; }
|
|
= new Dictionary<string, TimeSpan>();
|
|
protected ILogger Logger { get; set; }
|
|
|
|
protected readonly TempStream _tempStream;
|
|
protected readonly TenantManager _tenantManager;
|
|
protected readonly PathUtils _tpathUtils;
|
|
protected readonly EmailValidationKeyProvider _temailValidationKeyProvider;
|
|
protected readonly IHttpContextAccessor _httpContextAccessor;
|
|
protected readonly ILoggerProvider _options;
|
|
protected readonly IHttpClientFactory _clientFactory;
|
|
|
|
private readonly TenantQuotaFeatureStatHelper _tenantQuotaFeatureStatHelper;
|
|
private readonly QuotaSocketManager _quotaSocketManager;
|
|
|
|
public BaseStorage(
|
|
TempStream tempStream,
|
|
TenantManager tenantManager,
|
|
PathUtils pathUtils,
|
|
EmailValidationKeyProvider emailValidationKeyProvider,
|
|
IHttpContextAccessor httpContextAccessor,
|
|
ILoggerProvider options,
|
|
ILogger logger,
|
|
IHttpClientFactory clientFactory,
|
|
TenantQuotaFeatureStatHelper tenantQuotaFeatureStatHelper,
|
|
QuotaSocketManager quotaSocketManager)
|
|
{
|
|
|
|
_tempStream = tempStream;
|
|
_tenantManager = tenantManager;
|
|
_tpathUtils = pathUtils;
|
|
_temailValidationKeyProvider = emailValidationKeyProvider;
|
|
_options = options;
|
|
_clientFactory = clientFactory;
|
|
Logger = logger;
|
|
_httpContextAccessor = httpContextAccessor;
|
|
_tenantQuotaFeatureStatHelper = tenantQuotaFeatureStatHelper;
|
|
_quotaSocketManager = quotaSocketManager;
|
|
}
|
|
|
|
public TimeSpan GetExpire(string domain)
|
|
{
|
|
return DomainsExpires.ContainsKey(domain) ? DomainsExpires[domain] : DomainsExpires[string.Empty];
|
|
}
|
|
|
|
public async Task<Uri> GetUriAsync(string path)
|
|
{
|
|
return await GetUriAsync(string.Empty, path);
|
|
}
|
|
|
|
public async Task<Uri> GetUriAsync(string domain, string path)
|
|
{
|
|
return await GetPreSignedUriAsync(domain, path, TimeSpan.MaxValue, null);
|
|
}
|
|
|
|
public async Task<Uri> GetPreSignedUriAsync(string domain, string path, TimeSpan expire, IEnumerable<string> headers)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(path);
|
|
|
|
if (string.IsNullOrEmpty(Tenant) && IsSupportInternalUri)
|
|
{
|
|
return await GetInternalUriAsync(domain, path, expire, headers);
|
|
}
|
|
|
|
var headerAttr = string.Empty;
|
|
if (headers != null)
|
|
{
|
|
headerAttr = string.Join("&", headers.Select(HttpUtility.UrlEncode));
|
|
}
|
|
|
|
if (expire == TimeSpan.Zero || expire == TimeSpan.MinValue || expire == TimeSpan.MaxValue)
|
|
{
|
|
expire = GetExpire(domain);
|
|
}
|
|
|
|
var query = string.Empty;
|
|
if (expire != TimeSpan.Zero && expire != TimeSpan.MinValue && expire != TimeSpan.MaxValue)
|
|
{
|
|
var expireString = expire.TotalMinutes.ToString(CultureInfo.InvariantCulture);
|
|
|
|
int currentTenantId;
|
|
var currentTenant = await _tenantManager.GetCurrentTenantAsync(false);
|
|
if (currentTenant != null)
|
|
{
|
|
currentTenantId = currentTenant.Id;
|
|
}
|
|
else if (!TenantPath.TryGetTenant(Tenant, out currentTenantId))
|
|
{
|
|
currentTenantId = 0;
|
|
}
|
|
|
|
var auth = _temailValidationKeyProvider.GetEmailKey(currentTenantId, path.Replace('/', Path.DirectorySeparatorChar).Replace('\\', Path.DirectorySeparatorChar) + "." + headerAttr + "." + expireString);
|
|
query = $"{(path.IndexOf('?') >= 0 ? "&" : "?")}{Constants.QueryExpire}={expireString}&{Constants.QueryAuth}={auth}";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(headerAttr))
|
|
{
|
|
query += $"{(query.IndexOf('?') >= 0 ? "&" : "?")}{Constants.QueryHeader}={HttpUtility.UrlEncode(headerAttr)}";
|
|
}
|
|
|
|
var tenant = Tenant.Trim('/');
|
|
var vpath = _tpathUtils.ResolveVirtualPath(Modulename, domain);
|
|
vpath = _tpathUtils.ResolveVirtualPath(vpath, false);
|
|
vpath = string.Format(vpath, tenant);
|
|
var virtualPath = new Uri(vpath + "/", UriKind.RelativeOrAbsolute);
|
|
|
|
var uri = virtualPath.IsAbsoluteUri ?
|
|
new MonoUri(virtualPath, virtualPath.LocalPath.TrimEnd('/') + EnsureLeadingSlash(path.Replace('\\', '/')) + query) :
|
|
new MonoUri(virtualPath.ToString().TrimEnd('/') + EnsureLeadingSlash(path.Replace('\\', '/')) + query, UriKind.Relative);
|
|
|
|
return uri;
|
|
}
|
|
|
|
public virtual Task<Uri> GetInternalUriAsync(string domain, string path, TimeSpan expire, IEnumerable<string> headers)
|
|
{
|
|
return Task.FromResult<Uri>(null);
|
|
}
|
|
|
|
public virtual Task<Uri> GetCdnPreSignedUriAsync(string domain, string path, TimeSpan expire, IEnumerable<string> headers)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
public abstract Task<Stream> GetReadStreamAsync(string domain, string path);
|
|
|
|
public abstract Task<Stream> GetReadStreamAsync(string domain, string path, long offset);
|
|
|
|
public abstract Task<Uri> SaveAsync(string domain, string path, Stream stream);
|
|
public abstract Task<Uri> SaveAsync(string domain, string path, Stream stream, ACL acl);
|
|
|
|
public async Task<Uri> SaveAsync(string domain, string path, Stream stream, string attachmentFileName)
|
|
{
|
|
if (!string.IsNullOrEmpty(attachmentFileName))
|
|
{
|
|
return await SaveWithAutoAttachmentAsync(domain, path, stream, attachmentFileName);
|
|
}
|
|
return await SaveAsync(domain, path, stream);
|
|
}
|
|
|
|
protected abstract Task<Uri> SaveWithAutoAttachmentAsync(string domain, string path, Stream stream, string attachmentFileName);
|
|
|
|
|
|
public abstract Task<Uri> SaveAsync(string domain, string path, Stream stream, string contentType,
|
|
string contentDisposition);
|
|
public abstract Task<Uri> SaveAsync(string domain, string path, Stream stream, string contentEncoding, int cacheDays);
|
|
|
|
#region chunking
|
|
|
|
public virtual Task<string> InitiateChunkedUploadAsync(string domain, string path)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public virtual Task<string> UploadChunkAsync(string domain, string path, string uploadId, Stream stream, long defaultChunkSize, int chunkNumber, long chunkLength)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public virtual Task<Uri> FinalizeChunkedUploadAsync(string domain, string path, string uploadId, Dictionary<int, string> eTags)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public virtual Task AbortChunkedUploadAsync(string domain, string path, string uploadId)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
|
|
public virtual IDataWriteOperator CreateDataWriteOperator(
|
|
CommonChunkedUploadSession chunkedUploadSession,
|
|
CommonChunkedUploadSessionHolder sessionHolder)
|
|
{
|
|
return new ChunkZipWriteOperator(_tempStream, chunkedUploadSession, sessionHolder);
|
|
}
|
|
|
|
#endregion
|
|
|
|
public abstract Task DeleteAsync(string domain, string path);
|
|
public abstract Task DeleteFilesAsync(string domain, string folderPath, string pattern, bool recursive);
|
|
public abstract Task DeleteFilesAsync(string domain, List<string> paths);
|
|
public abstract Task DeleteFilesAsync(string domain, string folderPath, DateTime fromDate, DateTime toDate);
|
|
public abstract Task MoveDirectoryAsync(string srcdomain, string srcdir, string newdomain, string newdir);
|
|
public abstract Task<Uri> MoveAsync(string srcdomain, string srcpath, string newdomain, string newpath, bool quotaCheckFileSize = true);
|
|
public abstract Task<(Uri, string)> SaveTempAsync(string domain, Stream stream);
|
|
public abstract IAsyncEnumerable<string> ListDirectoriesRelativeAsync(string domain, string path, bool recursive);
|
|
public abstract IAsyncEnumerable<string> ListFilesRelativeAsync(string domain, string path, string pattern, bool recursive);
|
|
|
|
public abstract Task<bool> IsFileAsync(string domain, string path);
|
|
public abstract Task<bool> IsDirectoryAsync(string domain, string path);
|
|
public abstract Task DeleteDirectoryAsync(string domain, string path);
|
|
public abstract Task<long> GetFileSizeAsync(string domain, string path);
|
|
public abstract Task<long> GetDirectorySizeAsync(string domain, string path);
|
|
public abstract Task<long> ResetQuotaAsync(string domain);
|
|
public abstract Task<long> GetUsedQuotaAsync(string domain);
|
|
public abstract Task<Uri> CopyAsync(string srcdomain, string path, string newdomain, string newpath);
|
|
public abstract Task CopyDirectoryAsync(string srcdomain, string dir, string newdomain, string newdir);
|
|
|
|
public async Task<Stream> GetReadStreamAsync(string path)
|
|
{
|
|
return await GetReadStreamAsync(string.Empty, path);
|
|
}
|
|
|
|
public async Task<Uri> SaveAsync(string path, Stream stream, string attachmentFileName)
|
|
{
|
|
return await SaveAsync(string.Empty, path, stream, attachmentFileName);
|
|
}
|
|
|
|
public async Task<Uri> SaveAsync(string path, Stream stream)
|
|
{
|
|
return await SaveAsync(string.Empty, path, stream);
|
|
}
|
|
|
|
public async Task DeleteAsync(string path)
|
|
{
|
|
await DeleteAsync(string.Empty, path);
|
|
}
|
|
|
|
public async Task DeleteFilesAsync(string folderPath, string pattern, bool recursive)
|
|
{
|
|
await DeleteFilesAsync(string.Empty, folderPath, pattern, recursive);
|
|
}
|
|
|
|
public async Task<Uri> MoveAsync(string srcpath, string newdomain, string newpath)
|
|
{
|
|
return await MoveAsync(string.Empty, srcpath, newdomain, newpath);
|
|
}
|
|
|
|
public async Task<(Uri, string)> SaveTempAsync(Stream stream)
|
|
{
|
|
return await SaveTempAsync(string.Empty, stream);
|
|
}
|
|
|
|
public IAsyncEnumerable<string> ListDirectoriesRelativeAsync(string path, bool recursive)
|
|
{
|
|
return ListDirectoriesRelativeAsync(string.Empty, path, recursive);
|
|
}
|
|
|
|
public IAsyncEnumerable<Uri> ListFilesAsync(string path, string pattern, bool recursive)
|
|
{
|
|
return ListFilesAsync(string.Empty, path, pattern, recursive);
|
|
}
|
|
|
|
public async IAsyncEnumerable<Uri> ListFilesAsync(string domain, string path, string pattern, bool recursive)
|
|
{
|
|
var filePaths = ListFilesRelativeAsync(domain, path, pattern, recursive);
|
|
|
|
await foreach (var paths in filePaths)
|
|
{
|
|
yield return await GetUriAsync(domain, CrossPlatform.PathCombine(PathUtils.Normalize(path), paths));
|
|
}
|
|
}
|
|
|
|
public async Task<bool> IsFileAsync(string path)
|
|
{
|
|
return await IsFileAsync(string.Empty, path);
|
|
}
|
|
|
|
public async Task<bool> IsDirectoryAsync(string path)
|
|
{
|
|
return await IsDirectoryAsync(string.Empty, path);
|
|
}
|
|
|
|
public async Task DeleteDirectoryAsync(string path)
|
|
{
|
|
await DeleteDirectoryAsync(string.Empty, path);
|
|
}
|
|
|
|
public async Task<long> GetFileSizeAsync(string path)
|
|
{
|
|
return await GetFileSizeAsync(string.Empty, path);
|
|
}
|
|
|
|
public async Task<long> GetDirectorySizeAsync(string path)
|
|
{
|
|
return await GetDirectorySizeAsync(string.Empty, path);
|
|
}
|
|
|
|
public async Task<Uri> CopyAsync(string path, string newdomain, string newpath)
|
|
{
|
|
return await CopyAsync(string.Empty, path, newdomain, newpath);
|
|
}
|
|
|
|
public async Task CopyDirectoryAsync(string dir, string newdomain, string newdir)
|
|
{
|
|
await CopyDirectoryAsync(string.Empty, dir, newdomain, newdir);
|
|
}
|
|
|
|
public virtual IDataStore Configure(string tenant, Handler handlerConfig, Module moduleConfig, IDictionary<string, string> props)
|
|
{
|
|
return this;
|
|
}
|
|
|
|
public IDataStore SetQuotaController(IQuotaController controller)
|
|
{
|
|
QuotaController = controller;
|
|
|
|
return this;
|
|
}
|
|
|
|
public abstract Task<string> SavePrivateAsync(string domain, string path, Stream stream, DateTime expires);
|
|
public abstract Task DeleteExpiredAsync(string domain, string path, TimeSpan oldThreshold);
|
|
|
|
public abstract string GetUploadForm(string domain, string directoryPath, string redirectTo, long maxUploadSize,
|
|
string contentType, string contentDisposition, string submitLabel);
|
|
|
|
public abstract string GetUploadUrl();
|
|
|
|
public abstract string GetPostParams(string domain, string directoryPath, long maxUploadSize, string contentType,
|
|
string contentDisposition);
|
|
|
|
internal async Task QuotaUsedAddAsync(string domain, long size, bool quotaCheckFileSize = true)
|
|
{
|
|
if (QuotaController != null)
|
|
{
|
|
await QuotaController.QuotaUsedAddAsync(Modulename, domain, DataList.GetData(domain), size, quotaCheckFileSize);
|
|
var(name, value) = await _tenantQuotaFeatureStatHelper.GetStatAsync<MaxTotalSizeFeature, long>();
|
|
_ = _quotaSocketManager.ChangeQuotaUsedValueAsync(name, value);
|
|
}
|
|
}
|
|
|
|
internal async Task QuotaUsedDeleteAsync(string domain, long size)
|
|
{
|
|
if (QuotaController != null)
|
|
{
|
|
await QuotaController.QuotaUsedDeleteAsync(Modulename, domain, DataList.GetData(domain), size);
|
|
var (name, value) = await _tenantQuotaFeatureStatHelper.GetStatAsync<MaxTotalSizeFeature, long>();
|
|
_ = _quotaSocketManager.ChangeQuotaUsedValueAsync(name, value);
|
|
}
|
|
}
|
|
|
|
internal static string EnsureLeadingSlash(string str)
|
|
{
|
|
return "/" + str.TrimStart('/');
|
|
}
|
|
|
|
public abstract Task<string> GetFileEtagAsync(string domain, string path);
|
|
|
|
internal class MonoUri : Uri
|
|
{
|
|
public MonoUri(Uri baseUri, string relativeUri)
|
|
: base(baseUri, relativeUri) { }
|
|
|
|
public MonoUri(string uriString, UriKind uriKind)
|
|
: base(uriString, uriKind) { }
|
|
|
|
public override string ToString()
|
|
{
|
|
var s = base.ToString();
|
|
if (WorkContext.IsMono && s.StartsWith(UriSchemeFile + SchemeDelimiter))
|
|
{
|
|
return s.Substring(7);
|
|
}
|
|
|
|
return s;
|
|
}
|
|
}
|
|
}
|