2020-02-26 10:01:12 +00:00
/ *
*
* ( c ) Copyright Ascensio System Limited 2010 - 2018
*
* This program is freeware . You can redistribute it and / or modify it under the terms of the GNU
* General Public License ( GPL ) version 3 as published by the Free Software Foundation ( https : //www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7 ( a ) of the GNU GPL 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 more details , see GNU GPL at https : //www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales @onlyoffice . com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices , as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7 § 3 ( b ) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software . If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons , you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute .
* Pursuant to Section 7 § 3 ( e ) we decline to grant you any rights under trademark law for use of our trademarks .
*
* /
using System ;
using System.Collections.Generic ;
using System.Globalization ;
using System.Linq ;
2020-03-18 13:19:37 +00:00
using System.Text.Json ;
2020-07-09 09:02:44 +00:00
using System.Text.Json.Serialization ;
2020-02-26 10:01:12 +00:00
using System.Text.RegularExpressions ;
2021-11-15 11:31:47 +00:00
using System.Threading.Tasks ;
2020-02-26 10:01:12 +00:00
using ASC.Api.Core ;
using ASC.Api.Utils ;
using ASC.Common ;
using ASC.Core ;
using ASC.Core.Common.Configuration ;
using ASC.Core.Users ;
using ASC.FederatedLogin.Helpers ;
using ASC.FederatedLogin.LoginProviders ;
using ASC.Files.Core ;
2020-08-02 18:48:58 +00:00
using ASC.Files.Core.Model ;
2020-03-18 13:19:37 +00:00
using ASC.Files.Helpers ;
2020-02-26 10:01:12 +00:00
using ASC.Files.Model ;
using ASC.MessagingSystem ;
using ASC.Web.Api.Routing ;
using ASC.Web.Core.Files ;
using ASC.Web.Files.Classes ;
using ASC.Web.Files.Configuration ;
2021-11-16 17:40:15 +00:00
using ASC.Web.Files.Core.Compress ;
2020-02-26 10:01:12 +00:00
using ASC.Web.Files.Helpers ;
using ASC.Web.Files.Services.DocumentService ;
using ASC.Web.Files.Services.WCFService ;
using ASC.Web.Files.Services.WCFService.FileOperations ;
using ASC.Web.Files.Utils ;
2020-10-22 14:17:20 +00:00
using ASC.Web.Studio.Core ;
2020-02-26 10:01:12 +00:00
using ASC.Web.Studio.Utility ;
2020-12-01 07:20:15 +00:00
using Microsoft.AspNetCore.Authorization ;
2020-02-26 10:01:12 +00:00
using Microsoft.AspNetCore.Mvc ;
2022-01-28 14:42:11 +00:00
using Microsoft.Extensions.DependencyInjection ;
2020-02-26 10:01:12 +00:00
using Newtonsoft.Json.Linq ;
namespace ASC.Api.Documents
{
/// <summary>
/// Provides access to documents
/// </summary>
2020-10-19 19:04:07 +00:00
[Scope]
2020-02-26 10:01:12 +00:00
[DefaultRoute]
[ApiController]
2020-02-27 08:22:42 +00:00
public class FilesController : ControllerBase
2020-02-26 10:01:12 +00:00
{
2020-03-04 14:40:05 +00:00
private readonly FileStorageService < string > FileStorageService ;
2020-02-26 10:01:12 +00:00
2020-08-12 09:58:08 +00:00
private FilesControllerHelper < string > FilesControllerHelperString { get ; }
private FilesControllerHelper < int > FilesControllerHelperInt { get ; }
private FileStorageService < int > FileStorageServiceInt { get ; }
private GlobalFolderHelper GlobalFolderHelper { get ; }
private FilesSettingsHelper FilesSettingsHelper { get ; }
private FilesLinkUtility FilesLinkUtility { get ; }
private SecurityContext SecurityContext { get ; }
private FolderWrapperHelper FolderWrapperHelper { get ; }
private FileOperationWraperHelper FileOperationWraperHelper { get ; }
private EntryManager EntryManager { get ; }
private UserManager UserManager { get ; }
private CoreBaseSettings CoreBaseSettings { get ; }
private ThirdpartyConfiguration ThirdpartyConfiguration { get ; }
private MessageService MessageService { get ; }
private CommonLinkUtility CommonLinkUtility { get ; }
private DocumentServiceConnector DocumentServiceConnector { get ; }
private WordpressToken WordpressToken { get ; }
private WordpressHelper WordpressHelper { get ; }
private EasyBibHelper EasyBibHelper { get ; }
private ProductEntryPoint ProductEntryPoint { get ; }
2020-12-01 19:59:42 +00:00
private TenantManager TenantManager { get ; }
private FileUtility FileUtility { get ; }
2022-01-28 14:42:11 +00:00
private IServiceProvider ServiceProvider { get ; }
2020-02-26 10:01:12 +00:00
/// <summary>
/// </summary>
/// <param name="context"></param>
/// <param name="fileStorageService"></param>
2020-02-27 08:22:42 +00:00
public FilesController (
2020-03-18 13:19:37 +00:00
FilesControllerHelper < string > filesControllerHelperString ,
FilesControllerHelper < int > filesControllerHelperInt ,
2020-03-04 14:40:05 +00:00
FileStorageService < string > fileStorageService ,
FileStorageService < int > fileStorageServiceInt ,
2020-02-26 10:01:12 +00:00
GlobalFolderHelper globalFolderHelper ,
FilesSettingsHelper filesSettingsHelper ,
FilesLinkUtility filesLinkUtility ,
SecurityContext securityContext ,
FolderWrapperHelper folderWrapperHelper ,
FileOperationWraperHelper fileOperationWraperHelper ,
EntryManager entryManager ,
UserManager userManager ,
CoreBaseSettings coreBaseSettings ,
ThirdpartyConfiguration thirdpartyConfiguration ,
MessageService messageService ,
CommonLinkUtility commonLinkUtility ,
DocumentServiceConnector documentServiceConnector ,
WordpressToken wordpressToken ,
WordpressHelper wordpressHelper ,
2020-10-22 14:17:20 +00:00
ProductEntryPoint productEntryPoint ,
TenantManager tenantManager ,
2020-11-13 13:03:17 +00:00
FileUtility fileUtility ,
2021-11-16 17:40:15 +00:00
ConsumerFactory consumerFactory ,
2022-01-28 14:42:11 +00:00
IServiceProvider serviceProvider )
2020-02-26 10:01:12 +00:00
{
2020-03-18 13:19:37 +00:00
FilesControllerHelperString = filesControllerHelperString ;
FilesControllerHelperInt = filesControllerHelperInt ;
2020-02-26 10:01:12 +00:00
FileStorageService = fileStorageService ;
2020-03-04 14:40:05 +00:00
FileStorageServiceInt = fileStorageServiceInt ;
2020-02-26 10:01:12 +00:00
GlobalFolderHelper = globalFolderHelper ;
FilesSettingsHelper = filesSettingsHelper ;
FilesLinkUtility = filesLinkUtility ;
SecurityContext = securityContext ;
FolderWrapperHelper = folderWrapperHelper ;
FileOperationWraperHelper = fileOperationWraperHelper ;
EntryManager = entryManager ;
UserManager = userManager ;
CoreBaseSettings = coreBaseSettings ;
ThirdpartyConfiguration = thirdpartyConfiguration ;
MessageService = messageService ;
CommonLinkUtility = commonLinkUtility ;
DocumentServiceConnector = documentServiceConnector ;
WordpressToken = wordpressToken ;
WordpressHelper = wordpressHelper ;
2020-11-13 13:03:17 +00:00
EasyBibHelper = consumerFactory . Get < EasyBibHelper > ( ) ;
2020-02-26 10:01:12 +00:00
ProductEntryPoint = productEntryPoint ;
2020-10-22 14:17:20 +00:00
TenantManager = tenantManager ;
FileUtility = fileUtility ;
2022-01-28 14:42:11 +00:00
ServiceProvider = serviceProvider ;
2020-02-26 10:01:12 +00:00
}
[Read("info")]
public Module GetModule ( )
{
ProductEntryPoint . Init ( ) ;
2021-01-25 14:37:26 +00:00
return new Module ( ProductEntryPoint ) ;
2020-02-26 10:01:12 +00:00
}
2020-10-22 14:17:20 +00:00
[Read("@root")]
2021-11-26 09:32:24 +00:00
public async Task < IEnumerable < FolderContentWrapper < int > > > GetRootFoldersAsync ( Guid userIdOrGroupId , FilterType filterType , bool withsubfolders , bool withoutTrash , bool withoutAdditionalFolder )
2020-10-22 14:17:20 +00:00
{
var IsVisitor = UserManager . GetUsers ( SecurityContext . CurrentAccount . ID ) . IsVisitor ( UserManager ) ;
2021-05-06 10:27:15 +00:00
var IsOutsider = UserManager . GetUsers ( SecurityContext . CurrentAccount . ID ) . IsOutsider ( UserManager ) ;
2021-12-20 11:13:31 +00:00
var folders = new SortedSet < int > ( ) ;
2020-10-22 14:17:20 +00:00
2021-05-06 10:27:15 +00:00
if ( IsOutsider )
{
withoutTrash = true ;
withoutAdditionalFolder = true ;
}
2020-10-22 14:17:20 +00:00
if ( ! IsVisitor )
{
2021-11-26 09:32:24 +00:00
folders . Add ( GlobalFolderHelper . FolderMy ) ;
2020-10-22 14:17:20 +00:00
}
if ( ! CoreBaseSettings . Personal & & ! UserManager . GetUsers ( SecurityContext . CurrentAccount . ID ) . IsOutsider ( UserManager ) )
{
2022-01-18 16:50:31 +00:00
folders . Add ( await GlobalFolderHelper . FolderShareAsync ) ;
2020-10-22 14:17:20 +00:00
}
if ( ! IsVisitor & & ! withoutAdditionalFolder )
{
if ( FilesSettingsHelper . FavoritesSection )
{
2022-01-18 16:50:31 +00:00
folders . Add ( await GlobalFolderHelper . FolderFavoritesAsync ) ;
2020-10-22 14:17:20 +00:00
}
if ( FilesSettingsHelper . RecentSection )
{
2022-01-18 16:50:31 +00:00
folders . Add ( await GlobalFolderHelper . FolderRecentAsync ) ;
2020-10-22 14:17:20 +00:00
}
2021-07-09 15:41:07 +00:00
if ( ! CoreBaseSettings . Personal & & PrivacyRoomSettings . IsAvailable ( TenantManager ) )
2020-10-22 14:17:20 +00:00
{
2022-01-18 16:50:31 +00:00
folders . Add ( await GlobalFolderHelper . FolderPrivacyAsync ) ;
2020-10-22 14:17:20 +00:00
}
}
if ( ! CoreBaseSettings . Personal )
{
2022-01-18 16:50:31 +00:00
folders . Add ( await GlobalFolderHelper . FolderCommonAsync ) ;
2020-10-22 14:17:20 +00:00
}
if ( ! IsVisitor
& & ! withoutAdditionalFolder
2022-01-18 13:54:24 +00:00
& & FileUtility . ExtsWebTemplate . Count > 0
2020-10-22 14:17:20 +00:00
& & FilesSettingsHelper . TemplatesSection )
{
2022-01-18 16:50:31 +00:00
folders . Add ( await GlobalFolderHelper . FolderTemplatesAsync ) ;
2020-10-22 14:17:20 +00:00
}
2021-05-06 10:27:15 +00:00
if ( ! withoutTrash )
2020-10-22 14:17:20 +00:00
{
2021-11-26 09:32:24 +00:00
folders . Add ( ( int ) GlobalFolderHelper . FolderTrash ) ;
2021-11-15 11:31:47 +00:00
}
2021-11-26 09:32:24 +00:00
var result = new List < FolderContentWrapper < int > > ( ) ;
foreach ( var folder in folders )
2021-11-15 11:31:47 +00:00
{
2021-11-26 09:32:24 +00:00
result . Add ( await FilesControllerHelperInt . GetFolderAsync ( folder , userIdOrGroupId , filterType , withsubfolders ) ) ;
2021-11-15 11:31:47 +00:00
}
2021-11-26 09:32:24 +00:00
return result ;
2021-11-15 11:31:47 +00:00
}
2020-11-02 08:29:01 +00:00
[Read("@privacy")]
2022-02-16 12:57:37 +00:00
public Task < FolderContentWrapper < int > > GetPrivacyFolderAsync ( Guid userIdOrGroupId , FilterType filterType , bool withsubfolders )
2021-11-15 11:31:47 +00:00
{
if ( ! IsAvailablePrivacyRoomSettings ( ) ) throw new System . Security . SecurityException ( ) ;
2022-02-16 12:57:37 +00:00
return InternalGetPrivacyFolderAsync ( userIdOrGroupId , filterType , withsubfolders ) ;
}
private async Task < FolderContentWrapper < int > > InternalGetPrivacyFolderAsync ( Guid userIdOrGroupId , FilterType filterType , bool withsubfolders )
{
2022-01-18 16:50:31 +00:00
return await FilesControllerHelperInt . GetFolderAsync ( await GlobalFolderHelper . FolderPrivacyAsync , userIdOrGroupId , filterType , withsubfolders ) ;
2021-11-15 11:31:47 +00:00
}
2020-11-02 08:29:01 +00:00
[Read("@privacy/available")]
public bool IsAvailablePrivacyRoomSettings ( )
{
return PrivacyRoomSettings . IsAvailable ( TenantManager ) ;
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Returns the detailed list of files and folders located in the current user 'My Documents' section
/// </summary>
/// <short>
/// My folder
/// </short>
/// <category>Folders</category>
/// <returns>My folder contents</returns>
[Read("@my")]
2021-12-27 17:52:40 +00:00
public Task < FolderContentWrapper < int > > GetMyFolderAsync ( Guid userIdOrGroupId , FilterType filterType , bool withsubfolders )
2021-11-15 11:31:47 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . GetFolderAsync ( GlobalFolderHelper . FolderMy , userIdOrGroupId , filterType , withsubfolders ) ;
2021-11-15 11:31:47 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Returns the detailed list of files and folders located in the current user 'Projects Documents' section
/// </summary>
/// <short>
/// Projects folder
/// </short>
/// <category>Folders</category>
/// <returns>Projects folder contents</returns>
[Read("@projects")]
2022-01-18 16:50:31 +00:00
public async Task < FolderContentWrapper < string > > GetProjectsFolderAsync ( Guid userIdOrGroupId , FilterType filterType , bool withsubfolders )
2021-11-15 11:31:47 +00:00
{
2022-01-18 16:50:31 +00:00
return await FilesControllerHelperString . GetFolderAsync ( await GlobalFolderHelper . GetFolderProjectsAsync < string > ( ) , userIdOrGroupId , filterType , withsubfolders ) ;
2021-11-15 11:31:47 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Returns the detailed list of files and folders located in the 'Common Documents' section
/// </summary>
/// <short>
/// Common folder
/// </short>
/// <category>Folders</category>
/// <returns>Common folder contents</returns>
[Read("@common")]
2022-01-18 16:50:31 +00:00
public async Task < FolderContentWrapper < int > > GetCommonFolderAsync ( Guid userIdOrGroupId , FilterType filterType , bool withsubfolders )
2021-11-15 11:31:47 +00:00
{
2022-01-18 16:50:31 +00:00
return await FilesControllerHelperInt . GetFolderAsync ( await GlobalFolderHelper . FolderCommonAsync , userIdOrGroupId , filterType , withsubfolders ) ;
2021-11-15 11:31:47 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Returns the detailed list of files and folders located in the 'Shared with Me' section
/// </summary>
/// <short>
/// Shared folder
/// </short>
/// <category>Folders</category>
/// <returns>Shared folder contents</returns>
[Read("@share")]
2022-01-18 16:50:31 +00:00
public async Task < FolderContentWrapper < int > > GetShareFolderAsync ( Guid userIdOrGroupId , FilterType filterType , bool withsubfolders )
2021-11-15 11:31:47 +00:00
{
2022-01-18 16:50:31 +00:00
return await FilesControllerHelperInt . GetFolderAsync ( await GlobalFolderHelper . FolderShareAsync , userIdOrGroupId , filterType , withsubfolders ) ;
2021-11-15 11:31:47 +00:00
}
2020-09-22 14:17:17 +00:00
/// <summary>
/// Returns the detailed list of recent files
/// </summary>
/// <short>Section Recent</short>
/// <category>Folders</category>
/// <returns>Recent contents</returns>
2021-12-20 11:13:31 +00:00
[Read("@recent")]
2022-01-18 16:50:31 +00:00
public async Task < FolderContentWrapper < int > > GetRecentFolderAsync ( Guid userIdOrGroupId , FilterType filterType , bool withsubfolders )
2021-11-15 11:31:47 +00:00
{
2022-01-18 16:50:31 +00:00
return await FilesControllerHelperInt . GetFolderAsync ( await GlobalFolderHelper . FolderRecentAsync , userIdOrGroupId , filterType , withsubfolders ) ;
2021-11-15 11:31:47 +00:00
}
2021-12-20 11:13:31 +00:00
[Create("file/{fileId}/recent", order: int.MaxValue)]
2021-12-27 17:52:40 +00:00
public Task < FileWrapper < string > > AddToRecentAsync ( string fileId )
2021-11-22 08:30:38 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . AddToRecentAsync ( fileId ) ;
2021-11-22 08:30:38 +00:00
}
2021-12-20 11:13:31 +00:00
[Create("file/{fileId:int}/recent", order: int.MaxValue - 1)]
2021-12-27 17:52:40 +00:00
public Task < FileWrapper < int > > AddToRecentAsync ( int fileId )
2021-11-22 08:30:38 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . AddToRecentAsync ( fileId ) ;
2021-11-22 08:30:38 +00:00
}
2020-09-22 14:17:17 +00:00
/// <summary>
/// Returns the detailed list of favorites files
/// </summary>
/// <short>Section Favorite</short>
/// <category>Folders</category>
/// <returns>Favorites contents</returns>
[Read("@favorites")]
2022-01-18 16:50:31 +00:00
public async Task < FolderContentWrapper < int > > GetFavoritesFolderAsync ( Guid userIdOrGroupId , FilterType filterType , bool withsubfolders )
2021-11-15 11:31:47 +00:00
{
2022-01-18 16:50:31 +00:00
return await FilesControllerHelperInt . GetFolderAsync ( await GlobalFolderHelper . FolderFavoritesAsync , userIdOrGroupId , filterType , withsubfolders ) ;
2021-11-15 11:31:47 +00:00
}
2020-09-22 14:17:17 +00:00
/// <summary>
/// Returns the detailed list of templates files
/// </summary>
/// <short>Section Template</short>
/// <category>Folders</category>
/// <returns>Templates contents</returns>
2021-12-20 11:13:31 +00:00
[Read("@templates")]
2022-01-18 16:50:31 +00:00
public async Task < FolderContentWrapper < int > > GetTemplatesFolderAsync ( Guid userIdOrGroupId , FilterType filterType , bool withsubfolders )
2021-11-15 11:31:47 +00:00
{
2022-01-18 16:50:31 +00:00
return await FilesControllerHelperInt . GetFolderAsync ( await GlobalFolderHelper . FolderTemplatesAsync , userIdOrGroupId , filterType , withsubfolders ) ;
2021-11-15 11:31:47 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Returns the detailed list of files and folders located in the 'Recycle Bin' section
/// </summary>
/// <short>
/// Trash folder
/// </short>
/// <category>Folders</category>
/// <returns>Trash folder contents</returns>
[Read("@trash")]
2021-12-27 17:52:40 +00:00
public Task < FolderContentWrapper < int > > GetTrashFolderAsync ( Guid userIdOrGroupId , FilterType filterType , bool withsubfolders )
2021-11-15 11:31:47 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . GetFolderAsync ( Convert . ToInt32 ( GlobalFolderHelper . FolderTrash ) , userIdOrGroupId , filterType , withsubfolders ) ;
2021-11-15 11:31:47 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Returns the detailed list of files and folders located in the folder with the ID specified in the request
/// </summary>
/// <short>
/// Folder by ID
/// </short>
/// <category>Folders</category>
/// <param name="folderId">Folder ID</param>
/// <param name="userIdOrGroupId" optional="true">User or group ID</param>
/// <param name="filterType" optional="true" remark="Allowed values: None (0), FilesOnly (1), FoldersOnly (2), DocumentsOnly (3), PresentationsOnly (4), SpreadsheetsOnly (5) or ImagesOnly (7)">Filter type</param>
/// <returns>Folder contents</returns>
2021-12-20 11:13:31 +00:00
[Read("{folderId}", order: int.MaxValue, DisableFormat = true)]
2021-11-15 11:31:47 +00:00
public async Task < FolderContentWrapper < string > > GetFolderAsync ( string folderId , Guid userIdOrGroupId , FilterType filterType , bool withsubfolders )
{
var folder = await FilesControllerHelperString . GetFolderAsync ( folderId , userIdOrGroupId , filterType , withsubfolders ) ;
return folder . NotFoundIfNull ( ) ;
}
2021-12-20 11:13:31 +00:00
[Read("{folderId:int}", order: int.MaxValue - 1, DisableFormat = true)]
2021-12-27 17:52:40 +00:00
public Task < FolderContentWrapper < int > > GetFolderAsync ( int folderId , Guid userIdOrGroupId , FilterType filterType , bool withsubfolders )
2021-11-15 11:31:47 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . GetFolderAsync ( folderId , userIdOrGroupId , filterType , withsubfolders ) ;
2021-11-15 11:31:47 +00:00
}
2021-12-20 11:13:31 +00:00
[Read("{folderId}/subfolders")]
2022-02-11 18:18:12 +00:00
public IAsyncEnumerable < FileEntryWrapper > GetFoldersAsync ( string folderId )
2021-11-15 11:31:47 +00:00
{
2022-02-11 18:18:12 +00:00
return FilesControllerHelperString . GetFoldersAsync ( folderId ) ;
2021-06-11 11:24:01 +00:00
}
2021-12-20 11:13:31 +00:00
[Read("{folderId:int}/subfolders")]
2022-02-11 18:18:12 +00:00
public IAsyncEnumerable < FileEntryWrapper > GetFoldersAsync ( int folderId )
2021-11-22 08:30:38 +00:00
{
2022-02-11 18:18:12 +00:00
return FilesControllerHelperInt . GetFoldersAsync ( folderId ) ;
2020-06-25 17:17:24 +00:00
}
2021-12-20 11:13:31 +00:00
[Read("{folderId}/news")]
2021-12-27 17:52:40 +00:00
public Task < List < FileEntryWrapper > > GetNewItemsAsync ( string folderId )
2021-11-22 08:30:38 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . GetNewItemsAsync ( folderId ) ;
2021-11-22 08:30:38 +00:00
}
2020-06-25 17:17:24 +00:00
[Read("{folderId:int}/news")]
2021-12-27 17:52:40 +00:00
public Task < List < FileEntryWrapper > > GetNewItemsAsync ( int folderId )
2021-11-22 08:30:38 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . GetNewItemsAsync ( folderId ) ;
2021-11-22 08:30:38 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Uploads the file specified with single file upload or standart multipart/form-data method to 'My Documents' section
/// </summary>
/// <short>Upload to My</short>
/// <category>Uploads</category>
/// <remarks>
/// <![CDATA[
/// Upload can be done in 2 different ways:
/// <ol>
/// <li>Single file upload. You should set Content-Type & Content-Disposition header to specify filename and content type, and send file in request body</li>
/// <li>Using standart multipart/form-data method</li>
/// </ol>]]>
/// </remarks>
/// <param name="file" visible="false">Request Input stream</param>
/// <param name="contentType" visible="false">Content-Type Header</param>
/// <param name="contentDisposition" visible="false">Content-Disposition Header</param>
/// <param name="files" visible="false">List of files when posted as multipart/form-data</param>
/// <returns>Uploaded file</returns>
[Create("@my/upload")]
2022-02-11 18:18:12 +00:00
public Task < object > UploadFileToMyAsync ( [ ModelBinder ( BinderType = typeof ( UploadModelBinder ) ) ] UploadModel uploadModel )
2020-02-26 10:01:12 +00:00
{
uploadModel . CreateNewIfExist = false ;
2022-02-11 18:18:12 +00:00
return FilesControllerHelperInt . UploadFileAsync ( GlobalFolderHelper . FolderMy , uploadModel ) ;
2020-02-26 10:01:12 +00:00
}
/// <summary>
/// Uploads the file specified with single file upload or standart multipart/form-data method to 'Common Documents' section
/// </summary>
/// <short>Upload to Common</short>
/// <category>Uploads</category>
/// <remarks>
/// <![CDATA[
/// Upload can be done in 2 different ways:
/// <ol>
/// <li>Single file upload. You should set Content-Type & Content-Disposition header to specify filename and content type, and send file in request body</li>
/// <li>Using standart multipart/form-data method</li>
/// </ol>]]>
/// </remarks>
/// <param name="file" visible="false">Request Input stream</param>
/// <param name="contentType" visible="false">Content-Type Header</param>
/// <param name="contentDisposition" visible="false">Content-Disposition Header</param>
/// <param name="files" visible="false">List of files when posted as multipart/form-data</param>
/// <returns>Uploaded file</returns>
[Create("@common/upload")]
2021-11-22 08:30:38 +00:00
public async Task < object > UploadFileToCommonAsync ( [ ModelBinder ( BinderType = typeof ( UploadModelBinder ) ) ] UploadModel uploadModel )
2020-11-06 09:03:49 +00:00
{
uploadModel . CreateNewIfExist = false ;
2022-01-18 16:50:31 +00:00
return await FilesControllerHelperInt . UploadFileAsync ( await GlobalFolderHelper . FolderCommonAsync , uploadModel ) ;
2020-11-06 09:03:49 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Uploads the file specified with single file upload or standart multipart/form-data method to the selected folder
/// </summary>
/// <short>Upload to folder</short>
/// <category>Uploads</category>
/// <remarks>
/// <![CDATA[
/// Upload can be done in 2 different ways:
/// <ol>
/// <li>Single file upload. You should set Content-Type & Content-Disposition header to specify filename and content type, and send file in request body</li>
/// <li>Using standart multipart/form-data method</li>
/// </ol>]]>
/// </remarks>
/// <param name="folderId">Folder ID to upload to</param>
/// <param name="file" visible="false">Request Input stream</param>
/// <param name="contentType" visible="false">Content-Type Header</param>
/// <param name="contentDisposition" visible="false">Content-Disposition Header</param>
/// <param name="files" visible="false">List of files when posted as multipart/form-data</param>
/// <param name="createNewIfExist" visible="false">Create New If Exist</param>
/// <param name="storeOriginalFileFlag" visible="false">If True, upload documents in original formats as well</param>
/// <param name="keepConvertStatus" visible="false">Keep status conversation after finishing</param>
/// <returns>Uploaded file</returns>
2021-09-27 19:28:49 +00:00
[Create("{folderId}/upload", order: int.MaxValue)]
2022-02-11 18:18:12 +00:00
public Task < object > UploadFileAsync ( string folderId , [ ModelBinder ( BinderType = typeof ( UploadModelBinder ) ) ] UploadModel uploadModel )
2020-02-26 10:01:12 +00:00
{
2022-02-11 18:18:12 +00:00
return FilesControllerHelperString . UploadFileAsync ( folderId , uploadModel ) ;
2020-03-18 13:19:37 +00:00
}
2020-02-26 10:01:12 +00:00
2021-12-20 11:13:31 +00:00
[Create("{folderId:int}/upload", order: int.MaxValue - 1)]
2022-02-11 18:18:12 +00:00
public Task < object > UploadFileAsync ( int folderId , [ ModelBinder ( BinderType = typeof ( UploadModelBinder ) ) ] UploadModel uploadModel )
2020-03-18 13:19:37 +00:00
{
2022-02-11 18:18:12 +00:00
return FilesControllerHelperInt . UploadFileAsync ( folderId , uploadModel ) ;
2020-02-26 10:01:12 +00:00
}
/// <summary>
/// Uploads the file specified with single file upload to 'Common Documents' section
/// </summary>
/// <param name="file" visible="false">Request Input stream</param>
/// <param name="title">Name of file which has to be uploaded</param>
/// <param name="createNewIfExist" visible="false">Create New If Exist</param>
/// <param name="keepConvertStatus" visible="false">Keep status conversation after finishing</param>
/// <category>Uploads</category>
/// <returns></returns>
[Create("@my/insert")]
2022-02-11 18:18:12 +00:00
public Task < FileWrapper < int > > InsertFileToMyFromBodyAsync ( [ FromForm ] [ ModelBinder ( BinderType = typeof ( InsertFileModelBinder ) ) ] InsertFileModel model )
2021-11-22 08:30:38 +00:00
{
2022-02-11 18:18:12 +00:00
return InsertFileAsync ( GlobalFolderHelper . FolderMy , model ) ;
2021-11-22 08:30:38 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Uploads the file specified with single file upload to 'Common Documents' section
/// </summary>
/// <param name="file" visible="false">Request Input stream</param>
/// <param name="title">Name of file which has to be uploaded</param>
/// <param name="createNewIfExist" visible="false">Create New If Exist</param>
/// <param name="keepConvertStatus" visible="false">Keep status conversation after finishing</param>
/// <category>Uploads</category>
/// <returns></returns>
[Create("@common/insert")]
2021-11-22 08:30:38 +00:00
public async Task < FileWrapper < int > > InsertFileToCommonFromBodyAsync ( [ FromForm ] [ ModelBinder ( BinderType = typeof ( InsertFileModelBinder ) ) ] InsertFileModel model )
{
2022-01-18 16:50:31 +00:00
return await InsertFileAsync ( await GlobalFolderHelper . FolderCommonAsync , model ) ;
2021-11-22 08:30:38 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Uploads the file specified with single file upload
/// </summary>
/// <param name="folderId">Folder ID to upload to</param>
/// <param name="file" visible="false">Request Input stream</param>
/// <param name="title">Name of file which has to be uploaded</param>
/// <param name="createNewIfExist" visible="false">Create New If Exist</param>
/// <param name="keepConvertStatus" visible="false">Keep status conversation after finishing</param>
/// <category>Uploads</category>
/// <returns></returns>
2021-05-05 11:48:15 +00:00
[Create("{folderId}/insert", order: int.MaxValue)]
2022-02-11 18:18:12 +00:00
public Task < FileWrapper < string > > InsertFileAsync ( string folderId , [ FromForm ] [ ModelBinder ( BinderType = typeof ( InsertFileModelBinder ) ) ] InsertFileModel model )
2021-11-22 08:30:38 +00:00
{
2022-02-11 18:18:12 +00:00
return FilesControllerHelperString . InsertFileAsync ( folderId , model . Stream , model . Title , model . CreateNewIfExist , model . KeepConvertStatus ) ;
2020-03-18 13:19:37 +00:00
}
2021-01-21 07:42:23 +00:00
[Create("{folderId:int}/insert", order: int.MaxValue - 1)]
2022-02-11 18:18:12 +00:00
public Task < FileWrapper < int > > InsertFileFromFormAsync ( int folderId , [ FromForm ] [ ModelBinder ( BinderType = typeof ( InsertFileModelBinder ) ) ] InsertFileModel model )
2021-11-22 08:30:38 +00:00
{
2022-02-11 18:18:12 +00:00
return InsertFileAsync ( folderId , model ) ;
2021-11-22 08:30:38 +00:00
}
2021-12-27 17:52:40 +00:00
private Task < FileWrapper < int > > InsertFileAsync ( int folderId , InsertFileModel model )
2021-11-22 08:30:38 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . InsertFileAsync ( folderId , model . Stream , model . Title , model . CreateNewIfExist , model . KeepConvertStatus ) ;
2020-02-26 10:01:12 +00:00
}
/// <summary>
///
/// </summary>
/// <param name="file"></param>
/// <param name="fileId"></param>
/// <param name="encrypted"></param>
/// <returns></returns>
/// <visible>false</visible>
2020-11-10 10:41:32 +00:00
2021-05-05 11:48:15 +00:00
[Update("{fileId}/update")]
2022-02-11 18:18:12 +00:00
public Task < FileWrapper < string > > UpdateFileStreamFromFormAsync ( string fileId , [ FromForm ] FileStreamModel model )
2020-11-10 10:41:32 +00:00
{
2022-02-11 18:18:12 +00:00
return FilesControllerHelperString . UpdateFileStreamAsync ( FilesControllerHelperInt . GetFileFromRequest ( model ) . OpenReadStream ( ) , fileId , model . FileExtension , model . Encrypted , model . Forcesave ) ;
2020-11-10 10:41:32 +00:00
}
[Update("{fileId:int}/update")]
2022-02-11 18:18:12 +00:00
public Task < FileWrapper < int > > UpdateFileStreamFromFormAsync ( int fileId , [ FromForm ] FileStreamModel model )
2020-11-10 10:41:32 +00:00
{
2022-02-11 18:18:12 +00:00
return FilesControllerHelperInt . UpdateFileStreamAsync ( FilesControllerHelperInt . GetFileFromRequest ( model ) . OpenReadStream ( ) , fileId , model . FileExtension , model . Encrypted , model . Forcesave ) ;
2020-02-26 10:01:12 +00:00
}
/// <summary>
///
/// </summary>
/// <param name="fileId">File ID</param>
/// <param name="fileExtension"></param>
/// <param name="downloadUri"></param>
/// <param name="stream"></param>
/// <param name="doc"></param>
/// <param name="forcesave"></param>
/// <category>Files</category>
/// <returns></returns>
2021-05-05 11:48:15 +00:00
[Update("file/{fileId}/saveediting")]
2022-02-11 18:18:12 +00:00
public Task < FileWrapper < string > > SaveEditingFromFormAsync ( string fileId , [ FromForm ] SaveEditingModel model )
2021-11-22 08:30:38 +00:00
{
using var stream = FilesControllerHelperInt . GetFileFromRequest ( model ) . OpenReadStream ( ) ;
2022-02-11 18:18:12 +00:00
return FilesControllerHelperString . SaveEditingAsync ( fileId , model . FileExtension , model . DownloadUri , stream , model . Doc , model . Forcesave ) ;
2021-11-22 08:30:38 +00:00
}
2020-03-18 13:19:37 +00:00
[Update("file/{fileId:int}/saveediting")]
2022-02-11 18:18:12 +00:00
public Task < FileWrapper < int > > SaveEditingFromFormAsync ( int fileId , [ FromForm ] SaveEditingModel model )
2021-11-22 08:30:38 +00:00
{
using var stream = FilesControllerHelperInt . GetFileFromRequest ( model ) . OpenReadStream ( ) ;
2022-02-11 18:18:12 +00:00
return FilesControllerHelperInt . SaveEditingAsync ( fileId , model . FileExtension , model . DownloadUri , stream , model . Doc , model . Forcesave ) ;
2021-11-22 08:30:38 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
///
/// </summary>
/// <param name="fileId">File ID</param>
/// <param name="editingAlone"></param>
/// <param name="doc"></param>
/// <category>Files</category>
/// <returns></returns>
2021-05-05 11:48:15 +00:00
[Create("file/{fileId}/startedit")]
2021-10-06 19:43:28 +00:00
[Consumes("application/json")]
2021-11-15 11:31:47 +00:00
public async Task < object > StartEditFromBodyAsync ( string fileId , [ FromBody ] StartEditModel model )
{
return await FilesControllerHelperString . StartEditAsync ( fileId , model . EditingAlone , model . Doc ) ;
}
2021-05-05 11:48:15 +00:00
[Create("file/{fileId}/startedit")]
2020-11-06 09:03:49 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-11-15 11:31:47 +00:00
public async Task < object > StartEditFromFormAsync ( string fileId , [ FromForm ] StartEditModel model )
{
return await FilesControllerHelperString . StartEditAsync ( fileId , model . EditingAlone , model . Doc ) ;
}
2020-03-18 13:19:37 +00:00
[Create("file/{fileId:int}/startedit")]
2021-10-06 19:43:28 +00:00
[Consumes("application/json")]
2021-11-15 11:31:47 +00:00
public async Task < object > StartEditFromBodyAsync ( int fileId , [ FromBody ] StartEditModel model )
{
return await FilesControllerHelperInt . StartEditAsync ( fileId , model . EditingAlone , model . Doc ) ;
}
2021-10-06 19:43:28 +00:00
[Create("file/{fileId:int}/startedit")]
2021-11-22 08:30:38 +00:00
public async Task < object > StartEditAsync ( int fileId )
{
return await FilesControllerHelperInt . StartEditAsync ( fileId , false , null ) ;
}
2020-11-06 09:03:49 +00:00
[Create("file/{fileId:int}/startedit")]
[Consumes("application/x-www-form-urlencoded")]
2021-11-15 11:31:47 +00:00
public async Task < object > StartEditFromFormAsync ( int fileId , [ FromForm ] StartEditModel model )
{
return await FilesControllerHelperInt . StartEditAsync ( fileId , model . EditingAlone , model . Doc ) ;
}
2020-02-26 10:01:12 +00:00
/// <summary>
///
/// </summary>
/// <param name="fileId">File ID</param>
/// <param name="tabId"></param>
/// <param name="docKeyForTrack"></param>
/// <param name="doc"></param>
/// <param name="isFinish"></param>
/// <category>Files</category>
/// <returns></returns>
2021-05-05 11:48:15 +00:00
[Read("file/{fileId}/trackeditfile")]
2021-12-27 17:52:40 +00:00
public Task < KeyValuePair < bool , string > > TrackEditFileAsync ( string fileId , Guid tabId , string docKeyForTrack , string doc , bool isFinish )
2021-11-22 08:30:38 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . TrackEditFileAsync ( fileId , tabId , docKeyForTrack , doc , isFinish ) ;
2021-11-22 08:30:38 +00:00
}
2020-03-18 13:19:37 +00:00
[Read("file/{fileId:int}/trackeditfile")]
2021-12-27 17:52:40 +00:00
public Task < KeyValuePair < bool , string > > TrackEditFileAsync ( int fileId , Guid tabId , string docKeyForTrack , string doc , bool isFinish )
2021-11-22 08:30:38 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . TrackEditFileAsync ( fileId , tabId , docKeyForTrack , doc , isFinish ) ;
2021-11-22 08:30:38 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
///
/// </summary>
/// <param name="fileId">File ID</param>
/// <param name="version"></param>
/// <param name="doc"></param>
/// <category>Files</category>
/// <returns></returns>
2020-12-01 07:20:15 +00:00
[AllowAnonymous]
2021-05-23 16:11:25 +00:00
[Read("file/{fileId}/openedit", Check = false)]
2021-12-27 17:52:40 +00:00
public Task < Configuration < string > > OpenEditAsync ( string fileId , int version , string doc , bool view )
2020-02-26 10:01:12 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . OpenEditAsync ( fileId , version , doc , view ) ;
2020-03-18 13:19:37 +00:00
}
2020-02-26 10:01:12 +00:00
2020-12-01 07:20:15 +00:00
[AllowAnonymous]
2021-05-23 16:11:25 +00:00
[Read("file/{fileId:int}/openedit", Check = false)]
2021-12-27 17:52:40 +00:00
public Task < Configuration < int > > OpenEditAsync ( int fileId , int version , string doc , bool view )
2020-03-18 13:19:37 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . OpenEditAsync ( fileId , version , doc , view ) ;
2020-02-26 10:01:12 +00:00
}
/// <summary>
/// Creates session to upload large files in multiple chunks.
/// </summary>
/// <short>Chunked upload</short>
/// <category>Uploads</category>
/// <param name="folderId">Id of the folder in which file will be uploaded</param>
/// <param name="fileName">Name of file which has to be uploaded</param>
/// <param name="fileSize">Length in bytes of file which has to be uploaded</param>
/// <param name="relativePath">Relative folder from folderId</param>
/// <param name="encrypted" visible="false"></param>
/// <remarks>
/// <![CDATA[
2021-05-23 16:11:25 +00:00
/// Each chunk can have different length but its important what length is multiple of <b>512</b> and greater or equal than <b>10 mb</b>. Last chunk can have any size.
2020-02-26 10:01:12 +00:00
/// After initial request respond with status 200 OK you must obtain value of 'location' field from the response. Send all your chunks to that location.
/// Each chunk must be sent in strict order in which chunks appears in file.
/// After receiving each chunk if no errors occured server will respond with current information about upload session.
/// When number of uploaded bytes equal to the number of bytes you send in initial request server will respond with 201 Created and will send you info about uploaded file.
/// ]]>
/// </remarks>
/// <returns>
/// <![CDATA[
/// Information about created session. Which includes:
/// <ul>
/// <li><b>id:</b> unique id of this upload session</li>
/// <li><b>created:</b> UTC time when session was created</li>
/// <li><b>expired:</b> UTC time when session will be expired if no chunks will be sent until that time</li>
/// <li><b>location:</b> URL to which you must send your next chunk</li>
/// <li><b>bytes_uploaded:</b> If exists contains number of bytes uploaded for specific upload id</li>
/// <li><b>bytes_total:</b> Number of bytes which has to be uploaded</li>
/// </ul>
/// ]]>
/// </returns>
2021-05-05 11:48:15 +00:00
[Create("{folderId}/upload/create_session")]
2021-12-27 17:52:40 +00:00
public Task < object > CreateUploadSessionFromBodyAsync ( string folderId , [ FromBody ] SessionModel sessionModel )
2021-11-22 08:30:38 +00:00
{
2022-02-23 13:01:55 +00:00
return FilesControllerHelperString . CreateUploadSessionAsync ( folderId , sessionModel . FileName , sessionModel . FileSize , sessionModel . RelativePath , sessionModel . LastModified , sessionModel . Encrypted ) ;
2021-11-22 08:30:38 +00:00
}
2021-05-05 11:48:15 +00:00
[Create("{folderId}/upload/create_session")]
2020-11-06 09:03:49 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-12-27 17:52:40 +00:00
public Task < object > CreateUploadSessionFromFormAsync ( string folderId , [ FromForm ] SessionModel sessionModel )
2021-11-22 08:30:38 +00:00
{
2022-02-23 13:01:55 +00:00
return FilesControllerHelperString . CreateUploadSessionAsync ( folderId , sessionModel . FileName , sessionModel . FileSize , sessionModel . RelativePath , sessionModel . LastModified , sessionModel . Encrypted ) ;
2021-11-22 08:30:38 +00:00
}
2020-03-18 13:19:37 +00:00
[Create("{folderId:int}/upload/create_session")]
2021-12-27 17:52:40 +00:00
public Task < object > CreateUploadSessionFromBodyAsync ( int folderId , [ FromBody ] SessionModel sessionModel )
2021-11-22 08:30:38 +00:00
{
2022-02-23 13:01:55 +00:00
return FilesControllerHelperInt . CreateUploadSessionAsync ( folderId , sessionModel . FileName , sessionModel . FileSize , sessionModel . RelativePath , sessionModel . LastModified , sessionModel . Encrypted ) ;
2021-11-22 08:30:38 +00:00
}
2020-03-18 13:19:37 +00:00
[Create("{folderId:int}/upload/create_session")]
2020-11-06 09:03:49 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-12-27 17:52:40 +00:00
public Task < object > CreateUploadSessionFromFormAsync ( int folderId , [ FromForm ] SessionModel sessionModel )
2021-11-22 08:30:38 +00:00
{
2022-02-23 13:01:55 +00:00
return FilesControllerHelperInt . CreateUploadSessionAsync ( folderId , sessionModel . FileName , sessionModel . FileSize , sessionModel . RelativePath , sessionModel . LastModified , sessionModel . Encrypted ) ;
2021-11-22 08:30:38 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Creates a text (.txt) file in 'My Documents' section with the title and contents sent in the request
/// </summary>
/// <short>Create txt in 'My'</short>
/// <category>File Creation</category>
/// <param name="title">File title</param>
/// <param name="content">File contents</param>
/// <returns>Folder contents</returns>
[Create("@my/text")]
2021-12-27 17:52:40 +00:00
public Task < FileWrapper < int > > CreateTextFileInMyFromBodyAsync ( [ FromBody ] CreateTextOrHtmlFileModel model )
2021-11-22 08:30:38 +00:00
{
2021-12-27 17:52:40 +00:00
return CreateTextFileAsync ( GlobalFolderHelper . FolderMy , model ) ;
2021-11-22 08:30:38 +00:00
}
2020-11-10 10:41:32 +00:00
[Create("@my/text")]
[Consumes("application/x-www-form-urlencoded")]
2021-12-27 17:52:40 +00:00
public Task < FileWrapper < int > > CreateTextFileInMyFromFormAsync ( [ FromForm ] CreateTextOrHtmlFileModel model )
2021-11-22 08:30:38 +00:00
{
2021-12-27 17:52:40 +00:00
return CreateTextFileAsync ( GlobalFolderHelper . FolderMy , model ) ;
2021-11-22 08:30:38 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Creates a text (.txt) file in 'Common Documents' section with the title and contents sent in the request
/// </summary>
/// <short>Create txt in 'Common'</short>
/// <category>File Creation</category>
/// <param name="title">File title</param>
/// <param name="content">File contents</param>
/// <returns>Folder contents</returns>
[Create("@common/text")]
2022-01-18 16:50:31 +00:00
public async Task < FileWrapper < int > > CreateTextFileInCommonFromBodyAsync ( [ FromBody ] CreateTextOrHtmlFileModel model )
2021-11-22 08:30:38 +00:00
{
2022-01-18 16:50:31 +00:00
return await CreateTextFileAsync ( await GlobalFolderHelper . FolderCommonAsync , model ) ;
2021-11-22 08:30:38 +00:00
}
2020-11-10 10:41:32 +00:00
[Create("@common/text")]
[Consumes("application/x-www-form-urlencoded")]
2022-01-18 16:50:31 +00:00
public async Task < FileWrapper < int > > CreateTextFileInCommonFromFormAsync ( [ FromForm ] CreateTextOrHtmlFileModel model )
2021-11-22 08:30:38 +00:00
{
2022-01-18 16:50:31 +00:00
return await CreateTextFileAsync ( await GlobalFolderHelper . FolderCommonAsync , model ) ;
2021-11-22 08:30:38 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Creates a text (.txt) file in the selected folder with the title and contents sent in the request
/// </summary>
/// <short>Create txt</short>
/// <category>File Creation</category>
/// <param name="folderId">Folder ID</param>
/// <param name="title">File title</param>
/// <param name="content">File contents</param>
/// <returns>Folder contents</returns>
2021-05-05 11:48:15 +00:00
[Create("{folderId}/text")]
2021-12-27 17:52:40 +00:00
public Task < FileWrapper < string > > CreateTextFileFromBodyAsync ( string folderId , [ FromBody ] CreateTextOrHtmlFileModel model )
2021-11-22 08:30:38 +00:00
{
2021-12-27 17:52:40 +00:00
return CreateTextFileAsync ( folderId , model ) ;
2021-11-22 08:30:38 +00:00
}
2021-05-05 11:48:15 +00:00
[Create("{folderId}/text")]
2020-11-10 10:41:32 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-12-27 17:52:40 +00:00
public Task < FileWrapper < string > > CreateTextFileFromFormAsync ( string folderId , [ FromForm ] CreateTextOrHtmlFileModel model )
2021-11-22 08:30:38 +00:00
{
2021-12-27 17:52:40 +00:00
return CreateTextFileAsync ( folderId , model ) ;
2021-11-22 08:30:38 +00:00
}
2021-12-27 17:52:40 +00:00
private Task < FileWrapper < string > > CreateTextFileAsync ( string folderId , CreateTextOrHtmlFileModel model )
2021-11-22 08:30:38 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . CreateTextFileAsync ( folderId , model . Title , model . Content ) ;
2021-11-22 08:30:38 +00:00
}
2020-03-18 13:19:37 +00:00
[Create("{folderId:int}/text")]
2021-12-27 17:52:40 +00:00
public Task < FileWrapper < int > > CreateTextFileFromBodyAsync ( int folderId , [ FromBody ] CreateTextOrHtmlFileModel model )
2021-11-22 08:30:38 +00:00
{
2021-12-27 17:52:40 +00:00
return CreateTextFileAsync ( folderId , model ) ;
2021-11-22 08:30:38 +00:00
}
2020-03-18 13:19:37 +00:00
[Create("{folderId:int}/text")]
2021-01-27 18:11:47 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-12-27 17:52:40 +00:00
public Task < FileWrapper < int > > CreateTextFileFromFormAsync ( int folderId , [ FromForm ] CreateTextOrHtmlFileModel model )
2021-11-22 08:30:38 +00:00
{
2021-12-27 17:52:40 +00:00
return CreateTextFileAsync ( folderId , model ) ;
2021-11-22 08:30:38 +00:00
}
2021-12-27 17:52:40 +00:00
private Task < FileWrapper < int > > CreateTextFileAsync ( int folderId , CreateTextOrHtmlFileModel model )
2021-11-22 08:30:38 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . CreateTextFileAsync ( folderId , model . Title , model . Content ) ;
2021-11-22 08:30:38 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Creates an html (.html) file in the selected folder with the title and contents sent in the request
/// </summary>
/// <short>Create html</short>
/// <category>File Creation</category>
/// <param name="folderId">Folder ID</param>
/// <param name="title">File title</param>
/// <param name="content">File contents</param>
/// <returns>Folder contents</returns>
2021-05-05 11:48:15 +00:00
[Create("{folderId}/html")]
2021-12-27 17:52:40 +00:00
public Task < FileWrapper < string > > CreateHtmlFileFromBodyAsync ( string folderId , [ FromBody ] CreateTextOrHtmlFileModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return CreateHtmlFileAsync ( folderId , model ) ;
2021-11-22 13:17:27 +00:00
}
2021-05-05 11:48:15 +00:00
[Create("{folderId}/html")]
2020-11-10 10:41:32 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-12-27 17:52:40 +00:00
public Task < FileWrapper < string > > CreateHtmlFileFromFormAsync ( string folderId , [ FromForm ] CreateTextOrHtmlFileModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return CreateHtmlFileAsync ( folderId , model ) ;
2021-11-22 13:17:27 +00:00
}
2021-12-27 17:52:40 +00:00
private Task < FileWrapper < string > > CreateHtmlFileAsync ( string folderId , CreateTextOrHtmlFileModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . CreateHtmlFileAsync ( folderId , model . Title , model . Content ) ;
2021-11-22 13:17:27 +00:00
}
2020-03-18 13:19:37 +00:00
[Create("{folderId:int}/html")]
2021-12-27 17:52:40 +00:00
public Task < FileWrapper < int > > CreateHtmlFileFromBodyAsync ( int folderId , [ FromBody ] CreateTextOrHtmlFileModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return CreateHtmlFileAsync ( folderId , model ) ;
2021-11-22 13:17:27 +00:00
}
2020-03-18 13:19:37 +00:00
[Create("{folderId:int}/html")]
2020-11-10 10:41:32 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-12-27 17:52:40 +00:00
public Task < FileWrapper < int > > CreateHtmlFileFromFormAsync ( int folderId , [ FromForm ] CreateTextOrHtmlFileModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return CreateHtmlFileAsync ( folderId , model ) ;
2021-11-22 13:17:27 +00:00
}
2021-12-27 17:52:40 +00:00
private Task < FileWrapper < int > > CreateHtmlFileAsync ( int folderId , CreateTextOrHtmlFileModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . CreateHtmlFileAsync ( folderId , model . Title , model . Content ) ;
2021-11-22 13:17:27 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Creates an html (.html) file in 'My Documents' section with the title and contents sent in the request
/// </summary>
/// <short>Create html in 'My'</short>
/// <category>File Creation</category>
/// <param name="title">File title</param>
/// <param name="content">File contents</param>
/// <returns>Folder contents</returns>
2021-11-22 13:17:27 +00:00
[Create("@my/html")]
2021-12-27 17:52:40 +00:00
public Task < FileWrapper < int > > CreateHtmlFileInMyFromBodyAsync ( [ FromBody ] CreateTextOrHtmlFileModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return CreateHtmlFileAsync ( GlobalFolderHelper . FolderMy , model ) ;
2021-11-22 13:17:27 +00:00
}
2020-11-10 10:41:32 +00:00
[Create("@my/html")]
[Consumes("application/x-www-form-urlencoded")]
2021-12-27 17:52:40 +00:00
public Task < FileWrapper < int > > CreateHtmlFileInMyFromFormAsync ( [ FromForm ] CreateTextOrHtmlFileModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return CreateHtmlFileAsync ( GlobalFolderHelper . FolderMy , model ) ;
2021-11-22 13:17:27 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Creates an html (.html) file in 'Common Documents' section with the title and contents sent in the request
/// </summary>
/// <short>Create html in 'Common'</short>
/// <category>File Creation</category>
/// <param name="title">File title</param>
/// <param name="content">File contents</param>
/// <returns>Folder contents</returns>
[Create("@common/html")]
2022-01-18 16:50:31 +00:00
public async Task < FileWrapper < int > > CreateHtmlFileInCommonFromBodyAsync ( [ FromBody ] CreateTextOrHtmlFileModel model )
2021-11-22 13:17:27 +00:00
{
2022-01-18 16:50:31 +00:00
return await CreateHtmlFileAsync ( await GlobalFolderHelper . FolderCommonAsync , model ) ;
2021-11-22 13:17:27 +00:00
}
2020-11-10 10:41:32 +00:00
[Create("@common/html")]
[Consumes("application/x-www-form-urlencoded")]
2022-01-18 16:50:31 +00:00
public async Task < FileWrapper < int > > CreateHtmlFileInCommonFromFormAsync ( [ FromForm ] CreateTextOrHtmlFileModel model )
2021-11-22 13:17:27 +00:00
{
2022-01-18 16:50:31 +00:00
return await CreateHtmlFileAsync ( await GlobalFolderHelper . FolderCommonAsync , model ) ;
2021-11-22 13:17:27 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Creates a new folder with the title sent in the request. The ID of a parent folder can be also specified.
/// </summary>
/// <short>
/// New folder
/// </short>
/// <category>Folders</category>
/// <param name="folderId">Parent folder ID</param>
/// <param name="title">Title of new folder</param>
/// <returns>New folder contents</returns>
2021-09-30 18:26:01 +00:00
[Create("folder/{folderId}", order: int.MaxValue, DisableFormat = true)]
2021-12-27 17:52:40 +00:00
public Task < FolderWrapper < string > > CreateFolderFromBodyAsync ( string folderId , [ FromBody ] CreateFolderModel folderModel )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . CreateFolderAsync ( folderId , folderModel . Title ) ;
2021-11-22 13:17:27 +00:00
}
[Create("folder/{folderId}", order: int.MaxValue, DisableFormat = true)]
[Consumes("application/x-www-form-urlencoded")]
2021-12-27 17:52:40 +00:00
public Task < FolderWrapper < string > > CreateFolderFromFormAsync ( string folderId , [ FromForm ] CreateFolderModel folderModel )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . CreateFolderAsync ( folderId , folderModel . Title ) ;
2021-11-22 13:17:27 +00:00
}
[Create("folder/{folderId:int}", order: int.MaxValue - 1, DisableFormat = true)]
2021-12-27 17:52:40 +00:00
public Task < FolderWrapper < int > > CreateFolderFromBodyAsync ( int folderId , [ FromBody ] CreateFolderModel folderModel )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . CreateFolderAsync ( folderId , folderModel . Title ) ;
2021-11-22 13:17:27 +00:00
}
[Create("folder/{folderId:int}", order: int.MaxValue - 1, DisableFormat = true)]
[Consumes("application/x-www-form-urlencoded")]
2021-12-27 17:52:40 +00:00
public Task < FolderWrapper < int > > CreateFolderFromFormAsync ( int folderId , [ FromForm ] CreateFolderModel folderModel )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . CreateFolderAsync ( folderId , folderModel . Title ) ;
2021-11-22 13:17:27 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Creates a new file in the 'My Documents' section with the title sent in the request
/// </summary>
/// <short>Create file</short>
/// <category>File Creation</category>
/// <param name="title" remark="Allowed values: the file must have one of the following extensions: DOCX, XLSX, PPTX">File title</param>
/// <remarks>In case the extension for the file title differs from DOCX/XLSX/PPTX and belongs to one of the known text, spreadsheet or presentation formats, it will be changed to DOCX/XLSX/PPTX accordingly. If the file extension is not set or is unknown, the DOCX extension will be added to the file title.</remarks>
/// <returns>New file info</returns>
2020-11-06 09:03:49 +00:00
2021-11-22 13:17:27 +00:00
[Create("@my/file")]
2022-01-12 19:07:21 +00:00
public Task < FileWrapper < int > > CreateFileFromBodyAsync ( [ FromBody ] CreateFileModel < JsonElement > model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . CreateFileAsync ( GlobalFolderHelper . FolderMy , model . Title , model . TemplateId , model . EnableExternalExt ) ;
2021-11-22 13:17:27 +00:00
}
[Create("@my/file")]
[Consumes("application/x-www-form-urlencoded")]
2022-01-12 19:07:21 +00:00
public Task < FileWrapper < int > > CreateFileFromFormAsync ( [ FromForm ] CreateFileModel < JsonElement > model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . CreateFileAsync ( GlobalFolderHelper . FolderMy , model . Title , model . TemplateId , model . EnableExternalExt ) ;
2021-11-22 13:17:27 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Creates a new file in the specified folder with the title sent in the request
/// </summary>
/// <short>Create file</short>
/// <category>File Creation</category>
/// <param name="folderId">Folder ID</param>
/// <param name="title" remark="Allowed values: the file must have one of the following extensions: DOCX, XLSX, PPTX">File title</param>
/// <remarks>In case the extension for the file title differs from DOCX/XLSX/PPTX and belongs to one of the known text, spreadsheet or presentation formats, it will be changed to DOCX/XLSX/PPTX accordingly. If the file extension is not set or is unknown, the DOCX extension will be added to the file title.</remarks>
/// <returns>New file info</returns>
2021-11-22 13:17:27 +00:00
[Create("{folderId}/file")]
2022-01-12 19:07:21 +00:00
public Task < FileWrapper < string > > CreateFileFromBodyAsync ( string folderId , [ FromBody ] CreateFileModel < JsonElement > model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . CreateFileAsync ( folderId , model . Title , model . TemplateId , model . EnableExternalExt ) ;
2021-11-22 13:17:27 +00:00
}
[Create("{folderId}/file")]
[Consumes("application/x-www-form-urlencoded")]
2022-01-12 19:07:21 +00:00
public Task < FileWrapper < string > > CreateFileFromFormAsync ( string folderId , [ FromForm ] CreateFileModel < JsonElement > model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . CreateFileAsync ( folderId , model . Title , model . TemplateId , model . EnableExternalExt ) ;
2021-11-22 13:17:27 +00:00
}
[Create("{folderId:int}/file")]
2022-01-12 19:07:21 +00:00
public Task < FileWrapper < int > > CreateFileFromBodyAsync ( int folderId , [ FromBody ] CreateFileModel < JsonElement > model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . CreateFileAsync ( folderId , model . Title , model . TemplateId , model . EnableExternalExt ) ;
2021-11-22 13:17:27 +00:00
}
[Create("{folderId:int}/file")]
[Consumes("application/x-www-form-urlencoded")]
2022-01-12 19:07:21 +00:00
public Task < FileWrapper < int > > CreateFileFromFormAsync ( int folderId , [ FromForm ] CreateFileModel < JsonElement > model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . CreateFileAsync ( folderId , model . Title , model . TemplateId , model . EnableExternalExt ) ;
2021-11-22 13:17:27 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Renames the selected folder to the new title specified in the request
/// </summary>
/// <short>
/// Rename folder
/// </short>
/// <category>Folders</category>
/// <param name="folderId">Folder ID</param>
/// <param name="title">New title</param>
/// <returns>Folder contents</returns>
2020-11-06 09:03:49 +00:00
2021-11-22 13:17:27 +00:00
[Update("folder/{folderId}", order: int.MaxValue, DisableFormat = true)]
2021-12-27 17:52:40 +00:00
public Task < FolderWrapper < string > > RenameFolderFromBodyAsync ( string folderId , [ FromBody ] CreateFolderModel folderModel )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . RenameFolderAsync ( folderId , folderModel . Title ) ;
2021-11-22 13:17:27 +00:00
}
[Update("folder/{folderId}", order: int.MaxValue, DisableFormat = true)]
[Consumes("application/x-www-form-urlencoded")]
2021-12-27 17:52:40 +00:00
public Task < FolderWrapper < string > > RenameFolderFromFormAsync ( string folderId , [ FromForm ] CreateFolderModel folderModel )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . RenameFolderAsync ( folderId , folderModel . Title ) ;
2021-11-22 13:17:27 +00:00
}
[Update("folder/{folderId:int}", order: int.MaxValue - 1, DisableFormat = true)]
2021-12-27 17:52:40 +00:00
public Task < FolderWrapper < int > > RenameFolderFromBodyAsync ( int folderId , [ FromBody ] CreateFolderModel folderModel )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . RenameFolderAsync ( folderId , folderModel . Title ) ;
2021-11-22 13:17:27 +00:00
}
[Update("folder/{folderId:int}", order: int.MaxValue - 1, DisableFormat = true)]
[Consumes("application/x-www-form-urlencoded")]
2021-12-27 17:52:40 +00:00
public Task < FolderWrapper < int > > RenameFolderFromFormAsync ( int folderId , [ FromForm ] CreateFolderModel folderModel )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . RenameFolderAsync ( folderId , folderModel . Title ) ;
2021-11-22 13:17:27 +00:00
}
[Create("owner")]
2022-02-11 18:18:12 +00:00
public IAsyncEnumerable < FileEntryWrapper > ChangeOwnerFromBodyAsync ( [ FromBody ] ChangeOwnerModel model )
2021-11-22 13:17:27 +00:00
{
2022-02-11 18:18:12 +00:00
return ChangeOwnerAsync ( model ) ;
2021-11-22 13:17:27 +00:00
}
[Create("owner")]
[Consumes("application/x-www-form-urlencoded")]
2022-02-11 18:18:12 +00:00
public IAsyncEnumerable < FileEntryWrapper > ChangeOwnerFromFormAsync ( [ FromForm ] ChangeOwnerModel model )
2021-11-22 13:17:27 +00:00
{
2022-02-11 18:18:12 +00:00
return ChangeOwnerAsync ( model ) ;
2021-11-22 13:17:27 +00:00
}
public async IAsyncEnumerable < FileEntryWrapper > ChangeOwnerAsync ( ChangeOwnerModel model )
{
var ( folderIntIds , folderStringIds ) = FileOperationsManager . GetIds ( model . FolderIds ) ;
var ( fileIntIds , fileStringIds ) = FileOperationsManager . GetIds ( model . FileIds ) ;
2022-02-11 18:18:12 +00:00
var result = AsyncEnumerable . Empty < FileEntry > ( ) ;
result . Concat ( FileStorageServiceInt . ChangeOwnerAsync ( folderIntIds , fileIntIds , model . UserId ) ) ;
result . Concat ( FileStorageService . ChangeOwnerAsync ( folderStringIds , fileStringIds , model . UserId ) ) ;
2021-11-22 13:17:27 +00:00
2022-02-11 18:18:12 +00:00
await foreach ( var e in result )
2021-11-22 13:17:27 +00:00
{
yield return await FilesControllerHelperInt . GetFileEntryWrapperAsync ( e ) ;
}
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Returns a detailed information about the folder with the ID specified in the request
/// </summary>
/// <short>Folder information</short>
/// <category>Folders</category>
/// <returns>Folder info</returns>
2021-11-22 13:17:27 +00:00
[Read("folder/{folderId}", order: int.MaxValue, DisableFormat = true)]
2021-12-27 17:52:40 +00:00
public Task < FolderWrapper < string > > GetFolderInfoAsync ( string folderId )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . GetFolderInfoAsync ( folderId ) ;
2021-11-22 13:17:27 +00:00
}
[Read("folder/{folderId:int}", order: int.MaxValue - 1, DisableFormat = true)]
2021-12-27 17:52:40 +00:00
public Task < FolderWrapper < int > > GetFolderInfoAsync ( int folderId )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . GetFolderInfoAsync ( folderId ) ;
2021-11-22 13:17:27 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Returns parent folders
/// </summary>
/// <param name="folderId"></param>
/// <category>Folders</category>
/// <returns>Parent folders</returns>
2020-03-18 13:19:37 +00:00
2021-11-22 13:17:27 +00:00
[Read("folder/{folderId}/path")]
2022-02-22 09:22:15 +00:00
public IAsyncEnumerable < FileEntryWrapper > GetFolderPathAsync ( string folderId )
2021-11-22 13:17:27 +00:00
{
2022-02-11 18:18:12 +00:00
return FilesControllerHelperString . GetFolderPathAsync ( folderId ) ;
2021-11-22 13:17:27 +00:00
}
2020-02-26 10:01:12 +00:00
2021-11-22 13:17:27 +00:00
[Read("folder/{folderId:int}/path")]
2022-02-11 18:18:12 +00:00
public IAsyncEnumerable < FileEntryWrapper > GetFolderPathAsync ( int folderId )
2021-11-22 13:17:27 +00:00
{
2022-02-11 18:18:12 +00:00
return FilesControllerHelperInt . GetFolderPathAsync ( folderId ) ;
2021-11-22 13:17:27 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Returns a detailed information about the file with the ID specified in the request
/// </summary>
/// <short>File information</short>
/// <category>Files</category>
/// <returns>File info</returns>
2020-02-28 11:32:11 +00:00
2022-02-24 10:24:39 +00:00
[Read("file/{fileId}", order: int.MaxValue, DisableFormat = true)]
2021-12-27 17:52:40 +00:00
public Task < FileWrapper < string > > GetFileInfoAsync ( string fileId , int version = - 1 )
2021-11-15 11:31:47 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . GetFileInfoAsync ( fileId , version ) ;
2021-11-15 11:31:47 +00:00
}
2022-02-24 10:24:39 +00:00
[Read("file/{fileId:int}")]
2021-12-27 17:52:40 +00:00
public Task < FileWrapper < int > > GetFileInfoAsync ( int fileId , int version = - 1 )
2021-11-15 11:31:47 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . GetFileInfoAsync ( fileId , version ) ;
2021-11-15 11:31:47 +00:00
}
2021-11-29 14:52:50 +00:00
[Create("file/{fileId:int}/copyas", order: int.MaxValue - 1)]
2022-01-28 14:42:11 +00:00
public object CopyFileAsFromBody ( int fileId , [ FromBody ] CopyAsModel < JsonElement > model )
2021-11-29 11:11:03 +00:00
{
2022-01-28 14:42:11 +00:00
return CopyFile ( fileId , model ) ;
2021-11-29 14:52:50 +00:00
}
2021-11-29 11:11:03 +00:00
2021-11-29 14:52:50 +00:00
[Create("file/{fileId:int}/copyas", order: int.MaxValue - 1)]
[Consumes("application/x-www-form-urlencoded")]
2022-01-28 14:42:11 +00:00
public object CopyFileAsFromForm ( int fileId , [ FromForm ] CopyAsModel < JsonElement > model )
2021-11-29 14:52:50 +00:00
{
2022-01-28 14:42:11 +00:00
return CopyFile ( fileId , model ) ;
2021-11-29 14:52:50 +00:00
}
2021-11-29 11:11:03 +00:00
2021-11-29 14:52:50 +00:00
[Create("file/{fileId}/copyas", order: int.MaxValue)]
2022-01-28 14:42:11 +00:00
public object CopyFileAsFromBody ( string fileId , [ FromBody ] CopyAsModel < JsonElement > model )
2021-11-29 14:52:50 +00:00
{
2022-01-28 14:42:11 +00:00
return CopyFile ( fileId , model ) ;
2021-11-29 14:52:50 +00:00
}
2021-11-29 11:11:03 +00:00
2021-11-29 14:52:50 +00:00
[Create("file/{fileId}/copyas", order: int.MaxValue)]
[Consumes("application/x-www-form-urlencoded")]
2022-01-28 14:42:11 +00:00
public object CopyFileAsFromForm ( string fileId , [ FromForm ] CopyAsModel < JsonElement > model )
2021-11-29 14:52:50 +00:00
{
2022-01-28 14:42:11 +00:00
return CopyFile ( fileId , model ) ;
}
private object CopyFile < T > ( T fileId , CopyAsModel < JsonElement > model )
{
var helper = ServiceProvider . GetService < FilesControllerHelper < T > > ( ) ;
if ( model . DestFolderId . ValueKind = = JsonValueKind . Number )
{
2022-02-23 13:01:55 +00:00
return helper . CopyFileAsAsync ( fileId , model . DestFolderId . GetInt32 ( ) , model . DestTitle , model . Password ) ;
2022-01-28 14:42:11 +00:00
}
else if ( model . DestFolderId . ValueKind = = JsonValueKind . String )
{
2022-02-23 13:01:55 +00:00
return helper . CopyFileAsAsync ( fileId , model . DestFolderId . GetString ( ) , model . DestTitle , model . Password ) ;
2022-01-28 14:42:11 +00:00
}
return null ;
2021-11-29 11:11:03 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Updates the information of the selected file with the parameters specified in the request
/// </summary>
/// <short>Update file info</short>
/// <category>Files</category>
/// <param name="fileId">File ID</param>
/// <param name="title">New title</param>
/// <param name="lastVersion">File last version number</param>
/// <returns>File info</returns>
2022-02-24 10:24:39 +00:00
[Update("file/{fileId}", order: int.MaxValue, DisableFormat = true)]
2021-12-27 17:52:40 +00:00
public Task < FileWrapper < string > > UpdateFileFromBodyAsync ( string fileId , [ FromBody ] UpdateFileModel model )
2021-11-15 11:31:47 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . UpdateFileAsync ( fileId , model . Title , model . LastVersion ) ;
2021-11-15 11:31:47 +00:00
}
2022-02-24 10:24:39 +00:00
[Update("file/{fileId}", order: int.MaxValue, DisableFormat = true)]
2021-11-15 11:31:47 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-12-27 17:52:40 +00:00
public Task < FileWrapper < string > > UpdateFileFromFormAsync ( string fileId , [ FromForm ] UpdateFileModel model )
2021-11-15 11:31:47 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . UpdateFileAsync ( fileId , model . Title , model . LastVersion ) ;
2021-11-15 11:31:47 +00:00
}
2022-02-24 10:24:39 +00:00
[Update("file/{fileId:int}", order: int.MaxValue - 1, DisableFormat = true)]
2021-12-27 17:52:40 +00:00
public Task < FileWrapper < int > > UpdateFileFromBodyAsync ( int fileId , [ FromBody ] UpdateFileModel model )
2021-11-15 11:31:47 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . UpdateFileAsync ( fileId , model . Title , model . LastVersion ) ;
2021-11-15 11:31:47 +00:00
}
2022-02-24 10:24:39 +00:00
[Update("file/{fileId:int}", order: int.MaxValue - 1, DisableFormat = true)]
2021-11-15 11:31:47 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-12-27 17:52:40 +00:00
public Task < FileWrapper < int > > UpdateFileFromFormAsync ( int fileId , [ FromForm ] UpdateFileModel model )
2021-11-15 11:31:47 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . UpdateFileAsync ( fileId , model . Title , model . LastVersion ) ;
2021-11-15 11:31:47 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Deletes the file with the ID specified in the request
/// </summary>
/// <short>Delete file</short>
/// <category>Files</category>
/// <param name="fileId">File ID</param>
/// <param name="deleteAfter">Delete after finished</param>
/// <param name="immediately">Don't move to the Recycle Bin</param>
/// <returns>Operation result</returns>
2021-09-30 18:26:01 +00:00
[Delete("file/{fileId}", order: int.MaxValue, DisableFormat = true)]
2022-02-22 09:22:15 +00:00
public Task < IEnumerable < FileOperationWraper > > DeleteFile ( string fileId , [ FromBody ] DeleteModel model )
2020-02-26 10:01:12 +00:00
{
2022-02-22 09:22:15 +00:00
return FilesControllerHelperString . DeleteFileAsync ( fileId , model . DeleteAfter , model . Immediately ) ;
2020-03-18 13:19:37 +00:00
}
2020-02-26 10:01:12 +00:00
2021-09-30 18:26:01 +00:00
[Delete("file/{fileId:int}", order: int.MaxValue - 1, DisableFormat = true)]
2022-02-22 09:22:15 +00:00
public Task < IEnumerable < FileOperationWraper > > DeleteFile ( int fileId , [ FromBody ] DeleteModel model )
2020-03-18 13:19:37 +00:00
{
2022-02-22 09:22:15 +00:00
return FilesControllerHelperInt . DeleteFileAsync ( fileId , model . DeleteAfter , model . Immediately ) ;
2020-02-26 10:01:12 +00:00
}
/// <summary>
/// Start conversion
/// </summary>
/// <short>Convert</short>
/// <category>File operations</category>
/// <param name="fileId"></param>
/// <returns>Operation result</returns>
2020-03-18 13:19:37 +00:00
2021-11-22 13:17:27 +00:00
[Update("file/{fileId}/checkconversion")]
2022-02-23 13:01:55 +00:00
public IAsyncEnumerable < ConversationResult < string > > StartConversion ( string fileId , [ FromBody ( EmptyBodyBehavior = Microsoft . AspNetCore . Mvc . ModelBinding . EmptyBodyBehavior . Allow ) ] CheckConversionModel < string > model )
2021-11-22 13:17:27 +00:00
{
2022-02-01 18:12:56 +00:00
if ( model = = null )
{
model = new CheckConversionModel < string > ( ) ;
2022-02-24 10:24:39 +00:00
}
2021-12-08 17:17:50 +00:00
model . FileId = fileId ;
2022-02-23 13:01:55 +00:00
return FilesControllerHelperString . StartConversionAsync ( model ) ;
2021-11-22 13:17:27 +00:00
}
[Update("file/{fileId:int}/checkconversion")]
2022-02-23 13:01:55 +00:00
public IAsyncEnumerable < ConversationResult < int > > StartConversion ( int fileId , [ FromBody ( EmptyBodyBehavior = Microsoft . AspNetCore . Mvc . ModelBinding . EmptyBodyBehavior . Allow ) ] CheckConversionModel < int > model )
2021-11-22 13:17:27 +00:00
{
2022-02-01 18:12:56 +00:00
if ( model = = null )
{
model = new CheckConversionModel < int > ( ) ;
2022-02-24 10:24:39 +00:00
}
2021-12-08 17:17:50 +00:00
model . FileId = fileId ;
2022-02-23 13:01:55 +00:00
return FilesControllerHelperInt . StartConversionAsync ( model ) ;
2021-11-22 13:17:27 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Check conversion status
/// </summary>
/// <short>Convert</short>
/// <category>File operations</category>
/// <param name="fileId"></param>
/// <param name="start"></param>
/// <returns>Operation result</returns>
2020-03-18 13:19:37 +00:00
2021-11-22 13:17:27 +00:00
[Read("file/{fileId}/checkconversion")]
2022-02-22 09:22:15 +00:00
public IAsyncEnumerable < ConversationResult < string > > CheckConversionAsync ( string fileId , bool start )
2021-11-22 13:17:27 +00:00
{
2022-02-23 13:01:55 +00:00
return FilesControllerHelperString . CheckConversionAsync ( new CheckConversionModel < string > ( )
2021-12-08 17:17:50 +00:00
{
FileId = fileId ,
StartConvert = start
} ) ;
2021-11-22 13:17:27 +00:00
}
2020-02-26 10:01:12 +00:00
2021-11-22 13:17:27 +00:00
[Read("file/{fileId:int}/checkconversion")]
2022-02-11 18:18:12 +00:00
public IAsyncEnumerable < ConversationResult < int > > CheckConversionAsync ( int fileId , bool start )
2021-11-22 13:17:27 +00:00
{
2022-02-23 13:01:55 +00:00
return FilesControllerHelperInt . CheckConversionAsync ( new CheckConversionModel < int > ( )
2021-12-08 17:17:50 +00:00
{
FileId = fileId ,
StartConvert = start
} ) ;
2021-11-22 13:17:27 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Deletes the folder with the ID specified in the request
/// </summary>
/// <short>Delete folder</short>
/// <category>Folders</category>
/// <param name="folderId">Folder ID</param>
/// <param name="deleteAfter">Delete after finished</param>
/// <param name="immediately">Don't move to the Recycle Bin</param>
/// <returns>Operation result</returns>
2021-09-30 18:26:01 +00:00
[Delete("folder/{folderId}", order: int.MaxValue - 1, DisableFormat = true)]
2022-02-22 09:22:15 +00:00
public Task < IEnumerable < FileOperationWraper > > DeleteFolder ( string folderId , bool deleteAfter , bool immediately )
2020-02-26 10:01:12 +00:00
{
2020-03-18 13:19:37 +00:00
return FilesControllerHelperString . DeleteFolder ( folderId , deleteAfter , immediately ) ;
}
2020-02-26 10:01:12 +00:00
2020-03-18 13:19:37 +00:00
[Delete("folder/{folderId:int}")]
2022-02-22 09:22:15 +00:00
public Task < IEnumerable < FileOperationWraper > > DeleteFolder ( int folderId , bool deleteAfter , bool immediately )
2020-03-18 13:19:37 +00:00
{
return FilesControllerHelperInt . DeleteFolder ( folderId , deleteAfter , immediately ) ;
2020-02-26 10:01:12 +00:00
}
/// <summary>
/// Checking for conflicts
/// </summary>
/// <category>File operations</category>
/// <param name="destFolderId">Destination folder ID</param>
/// <param name="folderIds">Folder ID list</param>
/// <param name="fileIds">File ID list</param>
/// <returns>Conflicts file ids</returns>
2021-11-22 13:17:27 +00:00
[Read("fileops/move")]
2022-02-11 18:18:12 +00:00
public IAsyncEnumerable < FileEntryWrapper > MoveOrCopyBatchCheckAsync ( [ ModelBinder ( BinderType = typeof ( BatchModelBinder ) ) ] BatchModel batchModel )
2021-11-22 13:17:27 +00:00
{
2022-02-11 18:18:12 +00:00
return FilesControllerHelperString . MoveOrCopyBatchCheckAsync ( batchModel ) ;
2021-11-22 13:17:27 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Moves all the selected files and folders to the folder with the ID specified in the request
/// </summary>
/// <short>Move to folder</short>
/// <category>File operations</category>
/// <param name="destFolderId">Destination folder ID</param>
/// <param name="folderIds">Folder ID list</param>
/// <param name="fileIds">File ID list</param>
/// <param name="conflictResolveType">Overwriting behavior: skip(0), overwrite(1) or duplicate(2)</param>
/// <param name="deleteAfter">Delete after finished</param>
/// <returns>Operation result</returns>
[Update("fileops/move")]
2022-02-22 09:22:15 +00:00
public Task < IEnumerable < FileOperationWraper > > MoveBatchItemsFromBody ( [ FromBody ] BatchModel batchModel )
2020-11-06 09:03:49 +00:00
{
2022-02-22 09:22:15 +00:00
return FilesControllerHelperString . MoveBatchItemsAsync ( batchModel ) ;
2020-11-06 09:03:49 +00:00
}
[Update("fileops/move")]
[Consumes("application/x-www-form-urlencoded")]
2022-02-22 09:22:15 +00:00
public Task < IEnumerable < FileOperationWraper > > MoveBatchItemsFromForm ( [ FromForm ] [ ModelBinder ( BinderType = typeof ( BatchModelBinder ) ) ] BatchModel batchModel )
2020-02-26 10:01:12 +00:00
{
2022-02-22 09:22:15 +00:00
return FilesControllerHelperString . MoveBatchItemsAsync ( batchModel ) ;
2020-02-26 10:01:12 +00:00
}
/// <summary>
/// Copies all the selected files and folders to the folder with the ID specified in the request
/// </summary>
/// <short>Copy to folder</short>
/// <category>File operations</category>
/// <param name="destFolderId">Destination folder ID</param>
/// <param name="folderIds">Folder ID list</param>
/// <param name="fileIds">File ID list</param>
/// <param name="conflictResolveType">Overwriting behavior: skip(0), overwrite(1) or duplicate(2)</param>
/// <param name="deleteAfter">Delete after finished</param>
/// <returns>Operation result</returns>
[Update("fileops/copy")]
2022-02-22 09:22:15 +00:00
public Task < IEnumerable < FileOperationWraper > > CopyBatchItemsFromBody ( [ FromBody ] BatchModel batchModel )
2020-11-06 09:03:49 +00:00
{
2022-02-22 09:22:15 +00:00
return FilesControllerHelperString . CopyBatchItemsAsync ( batchModel ) ;
2020-11-06 09:03:49 +00:00
}
[Update("fileops/copy")]
[Consumes("application/x-www-form-urlencoded")]
2022-02-22 09:22:15 +00:00
public Task < IEnumerable < FileOperationWraper > > CopyBatchItemsFromForm ( [ FromForm ] [ ModelBinder ( BinderType = typeof ( BatchModelBinder ) ) ] BatchModel batchModel )
2020-02-26 10:01:12 +00:00
{
2022-02-22 09:22:15 +00:00
return FilesControllerHelperString . CopyBatchItemsAsync ( batchModel ) ;
2020-02-26 10:01:12 +00:00
}
/// <summary>
/// Marks all files and folders as read
/// </summary>
/// <short>Mark as read</short>
/// <category>File operations</category>
/// <returns>Operation result</returns>
[Update("fileops/markasread")]
2022-02-22 09:22:15 +00:00
public Task < IEnumerable < FileOperationWraper > > MarkAsReadFromBody ( [ FromBody ] BaseBatchModel model )
2020-11-06 09:03:49 +00:00
{
2022-02-22 09:22:15 +00:00
return FilesControllerHelperString . MarkAsReadAsync ( model ) ;
2020-11-06 09:03:49 +00:00
}
[Update("fileops/markasread")]
[Consumes("application/x-www-form-urlencoded")]
2022-02-22 09:22:15 +00:00
public Task < IEnumerable < FileOperationWraper > > MarkAsReadFromForm ( [ FromForm ] [ ModelBinder ( BinderType = typeof ( BaseBatchModelBinder ) ) ] BaseBatchModel model )
2020-02-26 10:01:12 +00:00
{
2022-02-22 09:22:15 +00:00
return FilesControllerHelperString . MarkAsReadAsync ( model ) ;
2020-02-26 10:01:12 +00:00
}
/// <summary>
/// Finishes all the active file operations
/// </summary>
/// <short>Finish all</short>
/// <category>File operations</category>
/// <returns>Operation result</returns>
2021-12-28 15:15:29 +00:00
2020-02-26 10:01:12 +00:00
[Update("fileops/terminate")]
2022-02-22 09:22:15 +00:00
public async IAsyncEnumerable < FileOperationWraper > TerminateTasks ( )
2020-02-26 10:01:12 +00:00
{
2022-02-22 09:22:15 +00:00
var tasks = FileStorageService . TerminateTasks ( ) ;
foreach ( var e in tasks )
{
yield return await FileOperationWraperHelper . GetAsync ( e ) ;
}
2020-02-26 10:01:12 +00:00
}
/// <summary>
/// Returns the list of all active file operations
/// </summary>
/// <short>Get file operations list</short>
/// <category>File operations</category>
/// <returns>Operation result</returns>
[Read("fileops")]
2022-02-22 09:22:15 +00:00
public async Task < IEnumerable < FileOperationWraper > > GetOperationStatuses ( )
2020-02-26 10:01:12 +00:00
{
2022-02-22 09:22:15 +00:00
var result = new List < FileOperationWraper > ( ) ;
foreach ( var e in FileStorageService . GetTasksStatuses ( ) )
{
result . Add ( await FileOperationWraperHelper . GetAsync ( e ) ) ;
}
return result ;
2020-02-26 10:01:12 +00:00
}
/// <summary>
/// Start downlaod process of files and folders with ID
/// </summary>
/// <short>Finish file operations</short>
/// <param name="fileConvertIds" visible="false">File ID list for download with convert to format</param>
/// <param name="fileIds">File ID list</param>
/// <param name="folderIds">Folder ID list</param>
/// <category>File operations</category>
/// <returns>Operation result</returns>
[Update("fileops/bulkdownload")]
2022-02-22 09:22:15 +00:00
public Task < IEnumerable < FileOperationWraper > > BulkDownload ( [ FromBody ] DownloadModel model )
2020-11-06 09:03:49 +00:00
{
2022-02-22 09:22:15 +00:00
return FilesControllerHelperString . BulkDownloadAsync ( model ) ;
2020-11-06 09:03:49 +00:00
}
[Update("fileops/bulkdownload")]
[Consumes("application/x-www-form-urlencoded")]
2022-02-22 09:22:15 +00:00
public Task < IEnumerable < FileOperationWraper > > BulkDownloadFromForm ( [ FromForm ] DownloadModel model )
2020-02-26 10:01:12 +00:00
{
2022-02-22 09:22:15 +00:00
return FilesControllerHelperString . BulkDownloadAsync ( model ) ;
2020-02-26 10:01:12 +00:00
}
/// <summary>
/// Deletes the files and folders with the IDs specified in the request
/// </summary>
/// <param name="folderIds">Folder ID list</param>
/// <param name="fileIds">File ID list</param>
/// <param name="deleteAfter">Delete after finished</param>
/// <param name="immediately">Don't move to the Recycle Bin</param>
/// <short>Delete files and folders</short>
/// <category>File operations</category>
/// <returns>Operation result</returns>
[Update("fileops/delete")]
2022-02-22 09:22:15 +00:00
public async IAsyncEnumerable < FileOperationWraper > DeleteBatchItemsFromBody ( [ FromBody ] DeleteBatchModel batch )
2020-11-06 09:03:49 +00:00
{
2022-02-22 09:22:15 +00:00
var tasks = FileStorageService . DeleteItems ( "delete" , batch . FileIds . ToList ( ) , batch . FolderIds . ToList ( ) , false , batch . DeleteAfter , batch . Immediately ) ;
foreach ( var e in tasks )
{
yield return await FileOperationWraperHelper . GetAsync ( e ) ;
}
2020-11-06 09:03:49 +00:00
}
[Update("fileops/delete")]
[Consumes("application/x-www-form-urlencoded")]
2022-02-22 09:22:15 +00:00
public async IAsyncEnumerable < FileOperationWraper > DeleteBatchItemsFromForm ( [ FromForm ] [ ModelBinder ( BinderType = typeof ( DeleteBatchModelBinder ) ) ] DeleteBatchModel batch )
2020-02-26 10:01:12 +00:00
{
2022-02-22 09:22:15 +00:00
var tasks = FileStorageService . DeleteItems ( "delete" , batch . FileIds . ToList ( ) , batch . FolderIds . ToList ( ) , false , batch . DeleteAfter , batch . Immediately ) ;
foreach ( var e in tasks )
{
yield return await FileOperationWraperHelper . GetAsync ( e ) ;
}
2020-02-26 10:01:12 +00:00
}
/// <summary>
/// Deletes all files and folders from the recycle bin
/// </summary>
/// <short>Clear recycle bin</short>
/// <category>File operations</category>
/// <returns>Operation result</returns>
[Update("fileops/emptytrash")]
2022-01-18 16:50:31 +00:00
public Task < IEnumerable < FileOperationWraper > > EmptyTrashAsync ( )
2020-02-26 10:01:12 +00:00
{
2022-01-18 16:50:31 +00:00
return FilesControllerHelperInt . EmptyTrashAsync ( ) ;
2020-02-26 10:01:12 +00:00
}
/// <summary>
/// Returns the detailed information about all the available file versions with the ID specified in the request
/// </summary>
/// <short>File versions</short>
/// <category>Files</category>
/// <param name="fileId">File ID</param>
/// <returns>File information</returns>
2021-11-22 13:17:27 +00:00
[Read("file/{fileId}/history")]
2021-12-27 17:52:40 +00:00
public Task < IEnumerable < FileWrapper < string > > > GetFileVersionInfoAsync ( string fileId )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . GetFileVersionInfoAsync ( fileId ) ;
2021-11-22 13:17:27 +00:00
}
[Read("file/{fileId:int}/history")]
2021-12-27 17:52:40 +00:00
public Task < IEnumerable < FileWrapper < int > > > GetFileVersionInfoAsync ( int fileId )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . GetFileVersionInfoAsync ( fileId ) ;
2021-11-22 13:17:27 +00:00
}
[Read("file/{fileId}/presigned")]
2021-12-27 17:52:40 +00:00
public Task < DocumentService . FileLink > GetPresignedUriAsync ( string fileId )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . GetPresignedUriAsync ( fileId ) ;
2021-11-22 13:17:27 +00:00
}
[Read("file/{fileId:int}/presigned")]
2021-12-27 17:52:40 +00:00
public Task < DocumentService . FileLink > GetPresignedUriAsync ( int fileId )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . GetPresignedUriAsync ( fileId ) ;
2021-11-22 13:17:27 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Change version history
/// </summary>
/// <param name="fileId">File ID</param>
/// <param name="version">Version of history</param>
/// <param name="continueVersion">Mark as version or revision</param>
/// <category>Files</category>
2021-11-26 09:32:24 +00:00
/// <returns></returns>
2020-11-06 09:03:49 +00:00
2021-11-22 13:17:27 +00:00
[Update("file/{fileId}/history")]
2021-12-27 17:52:40 +00:00
public Task < IEnumerable < FileWrapper < string > > > ChangeHistoryFromBodyAsync ( string fileId , [ FromBody ] ChangeHistoryModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . ChangeHistoryAsync ( fileId , model . Version , model . ContinueVersion ) ;
2021-11-22 13:17:27 +00:00
}
[Update("file/{fileId}/history")]
[Consumes("application/x-www-form-urlencoded")]
2021-12-27 17:52:40 +00:00
public Task < IEnumerable < FileWrapper < string > > > ChangeHistoryFromFormAsync ( string fileId , [ FromForm ] ChangeHistoryModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . ChangeHistoryAsync ( fileId , model . Version , model . ContinueVersion ) ;
2021-11-22 13:17:27 +00:00
}
[Update("file/{fileId:int}/history")]
2021-12-27 17:52:40 +00:00
public Task < IEnumerable < FileWrapper < int > > > ChangeHistoryFromBodyAsync ( int fileId , [ FromBody ] ChangeHistoryModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . ChangeHistoryAsync ( fileId , model . Version , model . ContinueVersion ) ;
2021-11-22 13:17:27 +00:00
}
[Update("file/{fileId:int}/history")]
[Consumes("application/x-www-form-urlencoded")]
2021-12-27 17:52:40 +00:00
public Task < IEnumerable < FileWrapper < int > > > ChangeHistoryFromFormAsync ( int fileId , [ FromForm ] ChangeHistoryModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . ChangeHistoryAsync ( fileId , model . Version , model . ContinueVersion ) ;
2021-11-22 13:17:27 +00:00
}
[Update("file/{fileId}/lock")]
2021-12-27 17:52:40 +00:00
public Task < FileWrapper < string > > LockFileFromBodyAsync ( string fileId , [ FromBody ] LockFileModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . LockFileAsync ( fileId , model . LockFile ) ;
2021-11-22 13:17:27 +00:00
}
[Update("file/{fileId}/lock")]
[Consumes("application/x-www-form-urlencoded")]
2021-12-27 17:52:40 +00:00
public Task < FileWrapper < string > > LockFileFromFormAsync ( string fileId , [ FromForm ] LockFileModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . LockFileAsync ( fileId , model . LockFile ) ;
2021-11-22 13:17:27 +00:00
}
[Update("file/{fileId:int}/lock")]
2021-12-27 17:52:40 +00:00
public Task < FileWrapper < int > > LockFileFromBodyAsync ( int fileId , [ FromBody ] LockFileModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . LockFileAsync ( fileId , model . LockFile ) ;
2021-11-22 13:17:27 +00:00
}
[Update("file/{fileId:int}/lock")]
[Consumes("application/x-www-form-urlencoded")]
2021-12-27 17:52:40 +00:00
public Task < FileWrapper < int > > LockFileFromFormAsync ( int fileId , [ FromForm ] LockFileModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . LockFileAsync ( fileId , model . LockFile ) ;
2021-11-22 13:17:27 +00:00
}
2021-12-08 12:25:39 +00:00
[AllowAnonymous]
[Read("file/{fileId}/edit/history")]
2022-01-12 19:07:21 +00:00
public Task < List < EditHistoryWrapper > > GetEditHistoryAsync ( string fileId , string doc = null )
2021-12-08 12:25:39 +00:00
{
2022-01-12 19:07:21 +00:00
return FilesControllerHelperString . GetEditHistoryAsync ( fileId , doc ) ;
2021-12-08 12:25:39 +00:00
}
[AllowAnonymous]
[Read("file/{fileId:int}/edit/history")]
2022-01-12 19:07:21 +00:00
public Task < List < EditHistoryWrapper > > GetEditHistoryAsync ( int fileId , string doc = null )
2021-12-08 12:25:39 +00:00
{
2022-01-12 19:07:21 +00:00
return FilesControllerHelperInt . GetEditHistoryAsync ( fileId , doc ) ;
2021-12-08 12:25:39 +00:00
}
[AllowAnonymous]
[Read("file/{fileId}/edit/diff")]
2022-01-12 19:07:21 +00:00
public Task < EditHistoryData > GetEditDiffUrlAsync ( string fileId , int version = 0 , string doc = null )
2021-12-08 12:25:39 +00:00
{
2022-01-12 19:07:21 +00:00
return FilesControllerHelperString . GetEditDiffUrlAsync ( fileId , version , doc ) ;
2021-12-08 12:25:39 +00:00
}
[AllowAnonymous]
[Read("file/{fileId:int}/edit/diff")]
2022-01-12 19:07:21 +00:00
public Task < EditHistoryData > GetEditDiffUrlAsync ( int fileId , int version = 0 , string doc = null )
2021-12-08 12:25:39 +00:00
{
2022-01-12 19:07:21 +00:00
return FilesControllerHelperInt . GetEditDiffUrlAsync ( fileId , version , doc ) ;
2021-12-08 12:25:39 +00:00
}
[AllowAnonymous]
[Read("file/{fileId}/restoreversion")]
2022-01-12 19:07:21 +00:00
public Task < List < EditHistoryWrapper > > RestoreVersionAsync ( string fileId , int version = 0 , string url = null , string doc = null )
2021-12-08 12:25:39 +00:00
{
2022-01-12 19:07:21 +00:00
return FilesControllerHelperString . RestoreVersionAsync ( fileId , version , url , doc ) ;
2021-12-08 12:25:39 +00:00
}
[AllowAnonymous]
[Read("file/{fileId:int}/restoreversion")]
2022-01-12 19:07:21 +00:00
public Task < List < EditHistoryWrapper > > RestoreVersionAsync ( int fileId , int version = 0 , string url = null , string doc = null )
2021-12-08 12:25:39 +00:00
{
2022-01-12 19:07:21 +00:00
return FilesControllerHelperInt . RestoreVersionAsync ( fileId , version , url , doc ) ;
2021-12-08 12:25:39 +00:00
}
2021-11-22 13:17:27 +00:00
[Update("file/{fileId}/comment")]
public async Task < object > UpdateCommentFromBodyAsync ( string fileId , [ FromBody ] UpdateCommentModel model )
{
return await FilesControllerHelperString . UpdateCommentAsync ( fileId , model . Version , model . Comment ) ;
}
[Update("file/{fileId}/comment")]
[Consumes("application/x-www-form-urlencoded")]
public async Task < object > UpdateCommentFromFormAsync ( string fileId , [ FromForm ] UpdateCommentModel model )
{
return await FilesControllerHelperString . UpdateCommentAsync ( fileId , model . Version , model . Comment ) ;
}
[Update("file/{fileId:int}/comment")]
public async Task < object > UpdateCommentFromBodyAsync ( int fileId , [ FromBody ] UpdateCommentModel model )
{
return await FilesControllerHelperInt . UpdateCommentAsync ( fileId , model . Version , model . Comment ) ;
}
[Update("file/{fileId:int}/comment")]
[Consumes("application/x-www-form-urlencoded")]
public async Task < object > UpdateCommentFromFormAsync ( int fileId , [ FromForm ] UpdateCommentModel model )
{
return await FilesControllerHelperInt . UpdateCommentAsync ( fileId , model . Version , model . Comment ) ;
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Returns the detailed information about shared file with the ID specified in the request
/// </summary>
/// <short>File sharing</short>
/// <category>Sharing</category>
/// <param name="fileId">File ID</param>
/// <returns>Shared file information</returns>
2020-03-18 13:19:37 +00:00
2021-11-22 13:17:27 +00:00
[Read("file/{fileId}/share")]
2021-12-27 17:52:40 +00:00
public Task < IEnumerable < FileShareWrapper > > GetFileSecurityInfoAsync ( string fileId )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . GetFileSecurityInfoAsync ( fileId ) ;
2021-11-22 13:17:27 +00:00
}
[Read("file/{fileId:int}/share")]
2021-12-27 17:52:40 +00:00
public Task < IEnumerable < FileShareWrapper > > GetFileSecurityInfoAsync ( int fileId )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . GetFileSecurityInfoAsync ( fileId ) ;
2021-11-22 13:17:27 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Returns the detailed information about shared folder with the ID specified in the request
/// </summary>
/// <short>Folder sharing</short>
/// <param name="folderId">Folder ID</param>
/// <category>Sharing</category>
/// <returns>Shared folder information</returns>
2020-03-18 13:19:37 +00:00
2021-11-22 13:17:27 +00:00
[Read("folder/{folderId}/share")]
2021-12-27 17:52:40 +00:00
public Task < IEnumerable < FileShareWrapper > > GetFolderSecurityInfoAsync ( string folderId )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . GetFolderSecurityInfoAsync ( folderId ) ;
2021-11-22 13:17:27 +00:00
}
[Read("folder/{folderId:int}/share")]
2021-12-27 17:52:40 +00:00
public Task < IEnumerable < FileShareWrapper > > GetFolderSecurityInfoAsync ( int folderId )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . GetFolderSecurityInfoAsync ( folderId ) ;
2021-11-22 13:17:27 +00:00
}
[Create("share")]
public async Task < IEnumerable < FileShareWrapper > > GetSecurityInfoFromBodyAsync ( [ FromBody ] BaseBatchModel model )
{
var ( folderIntIds , folderStringIds ) = FileOperationsManager . GetIds ( model . FolderIds ) ;
var ( fileIntIds , fileStringIds ) = FileOperationsManager . GetIds ( model . FileIds ) ;
var result = new List < FileShareWrapper > ( ) ;
result . AddRange ( await FilesControllerHelperInt . GetSecurityInfoAsync ( fileIntIds , folderIntIds ) ) ;
result . AddRange ( await FilesControllerHelperString . GetSecurityInfoAsync ( fileStringIds , folderStringIds ) ) ;
return result ;
}
[Create("share")]
[Consumes("application/x-www-form-urlencoded")]
public async Task < IEnumerable < FileShareWrapper > > GetSecurityInfoFromFormAsync ( [ FromForm ] [ ModelBinder ( BinderType = typeof ( BaseBatchModelBinder ) ) ] BaseBatchModel model )
{
var ( folderIntIds , folderStringIds ) = FileOperationsManager . GetIds ( model . FolderIds ) ;
var ( fileIntIds , fileStringIds ) = FileOperationsManager . GetIds ( model . FileIds ) ;
var result = new List < FileShareWrapper > ( ) ;
result . AddRange ( await FilesControllerHelperInt . GetSecurityInfoAsync ( fileIntIds , folderIntIds ) ) ;
result . AddRange ( await FilesControllerHelperString . GetSecurityInfoAsync ( fileStringIds , folderStringIds ) ) ;
return result ;
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Sets sharing settings for the file with the ID specified in the request
/// </summary>
/// <param name="fileId">File ID</param>
/// <param name="share">Collection of sharing rights</param>
/// <param name="notify">Should notify people</param>
/// <param name="sharingMessage">Sharing message to send when notifying</param>
/// <short>Share file</short>
/// <category>Sharing</category>
/// <remarks>
/// Each of the FileShareParams must contain two parameters: 'ShareTo' - ID of the user with whom we want to share and 'Access' - access type which we want to grant to the user (Read, ReadWrite, etc)
/// </remarks>
/// <returns>Shared file information</returns>
2020-11-06 09:03:49 +00:00
2021-11-22 13:17:27 +00:00
[Update("file/{fileId}/share")]
2021-12-27 17:52:40 +00:00
public Task < IEnumerable < FileShareWrapper > > SetFileSecurityInfoFromBodyAsync ( string fileId , [ FromBody ] SecurityInfoModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . SetFileSecurityInfoAsync ( fileId , model . Share , model . Notify , model . SharingMessage ) ;
2021-11-22 13:17:27 +00:00
}
[Update("file/{fileId}/share")]
[Consumes("application/x-www-form-urlencoded")]
2021-12-27 17:52:40 +00:00
public Task < IEnumerable < FileShareWrapper > > SetFileSecurityInfoFromFormAsync ( string fileId , [ FromForm ] SecurityInfoModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . SetFileSecurityInfoAsync ( fileId , model . Share , model . Notify , model . SharingMessage ) ;
2021-11-22 13:17:27 +00:00
}
[Update("file/{fileId:int}/share")]
2021-12-27 17:52:40 +00:00
public Task < IEnumerable < FileShareWrapper > > SetFileSecurityInfoFromBodyAsync ( int fileId , [ FromBody ] SecurityInfoModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . SetFileSecurityInfoAsync ( fileId , model . Share , model . Notify , model . SharingMessage ) ;
2021-11-22 13:17:27 +00:00
}
[Update("file/{fileId:int}/share")]
[Consumes("application/x-www-form-urlencoded")]
2021-12-27 17:52:40 +00:00
public Task < IEnumerable < FileShareWrapper > > SetFileSecurityInfoFromFormAsync ( int fileId , [ FromForm ] SecurityInfoModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . SetFileSecurityInfoAsync ( fileId , model . Share , model . Notify , model . SharingMessage ) ;
2021-11-22 13:17:27 +00:00
}
[Update("share")]
2021-12-27 17:52:40 +00:00
public Task < IEnumerable < FileShareWrapper > > SetSecurityInfoFromBodyAsync ( [ FromBody ] SecurityInfoModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return SetSecurityInfoAsync ( model ) ;
2021-11-22 13:17:27 +00:00
}
[Update("share")]
[Consumes("application/x-www-form-urlencoded")]
2021-12-27 17:52:40 +00:00
public Task < IEnumerable < FileShareWrapper > > SetSecurityInfoFromFormAsync ( [ FromForm ] SecurityInfoModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return SetSecurityInfoAsync ( model ) ;
2021-11-22 13:17:27 +00:00
}
public async Task < IEnumerable < FileShareWrapper > > SetSecurityInfoAsync ( SecurityInfoModel model )
{
var ( folderIntIds , folderStringIds ) = FileOperationsManager . GetIds ( model . FolderIds ) ;
var ( fileIntIds , fileStringIds ) = FileOperationsManager . GetIds ( model . FileIds ) ;
var result = new List < FileShareWrapper > ( ) ;
result . AddRange ( await FilesControllerHelperInt . SetSecurityInfoAsync ( fileIntIds , folderIntIds , model . Share , model . Notify , model . SharingMessage ) ) ;
result . AddRange ( await FilesControllerHelperString . SetSecurityInfoAsync ( fileStringIds , folderStringIds , model . Share , model . Notify , model . SharingMessage ) ) ;
return result ;
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Sets sharing settings for the folder with the ID specified in the request
/// </summary>
/// <short>Share folder</short>
/// <param name="folderId">Folder ID</param>
/// <param name="share">Collection of sharing rights</param>
/// <param name="notify">Should notify people</param>
/// <param name="sharingMessage">Sharing message to send when notifying</param>
/// <remarks>
/// Each of the FileShareParams must contain two parameters: 'ShareTo' - ID of the user with whom we want to share and 'Access' - access type which we want to grant to the user (Read, ReadWrite, etc)
/// </remarks>
/// <category>Sharing</category>
/// <returns>Shared folder information</returns>
2020-11-06 09:03:49 +00:00
2021-11-22 13:17:27 +00:00
[Update("folder/{folderId}/share")]
2021-12-27 17:52:40 +00:00
public Task < IEnumerable < FileShareWrapper > > SetFolderSecurityInfoFromBodyAsync ( string folderId , [ FromBody ] SecurityInfoModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . SetFolderSecurityInfoAsync ( folderId , model . Share , model . Notify , model . SharingMessage ) ;
2021-11-22 13:17:27 +00:00
}
[Update("folder/{folderId}/share")]
[Consumes("application/x-www-form-urlencoded")]
2021-12-27 17:52:40 +00:00
public Task < IEnumerable < FileShareWrapper > > SetFolderSecurityInfoFromFormAsync ( string folderId , [ FromForm ] SecurityInfoModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . SetFolderSecurityInfoAsync ( folderId , model . Share , model . Notify , model . SharingMessage ) ;
2021-11-22 13:17:27 +00:00
}
[Update("folder/{folderId:int}/share")]
2021-12-27 17:52:40 +00:00
public Task < IEnumerable < FileShareWrapper > > SetFolderSecurityInfoFromBodyAsync ( int folderId , [ FromBody ] SecurityInfoModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . SetFolderSecurityInfoAsync ( folderId , model . Share , model . Notify , model . SharingMessage ) ;
2021-11-22 13:17:27 +00:00
}
[Update("folder/{folderId:int}/share")]
[Consumes("application/x-www-form-urlencoded")]
2021-12-27 17:52:40 +00:00
public Task < IEnumerable < FileShareWrapper > > SetFolderSecurityInfoFromFormAsync ( int folderId , [ FromForm ] SecurityInfoModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . SetFolderSecurityInfoAsync ( folderId , model . Share , model . Notify , model . SharingMessage ) ;
2021-11-22 13:17:27 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Removes sharing rights for the group with the ID specified in the request
/// </summary>
/// <param name="folderIds">Folders ID</param>
/// <param name="fileIds">Files ID</param>
/// <short>Remove group sharing rights</short>
/// <category>Sharing</category>
/// <returns>Shared file information</returns>
2021-11-22 13:17:27 +00:00
[Delete("share")]
public async Task < bool > RemoveSecurityInfoAsync ( BaseBatchModel model )
{
var ( folderIntIds , folderStringIds ) = FileOperationsManager . GetIds ( model . FolderIds ) ;
var ( fileIntIds , fileStringIds ) = FileOperationsManager . GetIds ( model . FileIds ) ;
await FilesControllerHelperInt . RemoveSecurityInfoAsync ( fileIntIds , folderIntIds ) ;
await FilesControllerHelperString . RemoveSecurityInfoAsync ( fileStringIds , folderStringIds ) ;
return true ;
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Returns the external link to the shared file with the ID specified in the request
/// </summary>
/// <summary>
/// File external link
/// </summary>
/// <param name="fileId">File ID</param>
/// <param name="share">Access right</param>
/// <category>Files</category>
/// <returns>Shared file link</returns>
2020-11-10 10:41:32 +00:00
2021-11-15 11:31:47 +00:00
[Update("{fileId}/sharedlinkAsync")]
public async Task < object > GenerateSharedLinkFromBodyAsync ( string fileId , [ FromBody ] GenerateSharedLinkModel model )
{
return await FilesControllerHelperString . GenerateSharedLinkAsync ( fileId , model . Share ) ;
}
[Update("{fileId}/sharedlinkAsync")]
[Consumes("application/x-www-form-urlencoded")]
public async Task < object > GenerateSharedLinkFromFormAsync ( string fileId , [ FromForm ] GenerateSharedLinkModel model )
{
return await FilesControllerHelperString . GenerateSharedLinkAsync ( fileId , model . Share ) ;
}
[Update("{fileId:int}/sharedlinkAsync")]
public async Task < object > GenerateSharedLinkFromBodyAsync ( int fileId , [ FromBody ] GenerateSharedLinkModel model )
{
return await FilesControllerHelperInt . GenerateSharedLinkAsync ( fileId , model . Share ) ;
}
[Update("{fileId:int}/sharedlinkAsync")]
[Consumes("application/x-www-form-urlencoded")]
public async Task < object > GenerateSharedLinkFromFormAsync ( int fileId , [ FromForm ] GenerateSharedLinkModel model )
{
return await FilesControllerHelperInt . GenerateSharedLinkAsync ( fileId , model . Share ) ;
}
2021-11-22 13:17:27 +00:00
[Update("{fileId:int}/setacelink")]
2021-12-27 17:52:40 +00:00
public Task < bool > SetAceLinkAsync ( int fileId , [ FromBody ] GenerateSharedLinkModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperInt . SetAceLinkAsync ( fileId , model . Share ) ;
2021-11-22 13:17:27 +00:00
}
[Update("{fileId}/setacelink")]
2021-12-27 17:52:40 +00:00
public Task < bool > SetAceLinkAsync ( string fileId , [ FromBody ] GenerateSharedLinkModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FilesControllerHelperString . SetAceLinkAsync ( fileId , model . Share ) ;
2021-11-22 13:17:27 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Get a list of available providers
/// </summary>
/// <category>Third-Party Integration</category>
/// <returns>List of provider key</returns>
/// <remarks>List of provider key: DropboxV2, Box, WebDav, Yandex, OneDrive, SharePoint, GoogleDrive</remarks>
/// <returns></returns>
[Read("thirdparty/capabilities")]
public List < List < string > > Capabilities ( )
{
var result = new List < List < string > > ( ) ;
if ( UserManager . GetUsers ( SecurityContext . CurrentAccount . ID ) . IsVisitor ( UserManager )
2020-09-22 14:17:17 +00:00
| | ( ! FilesSettingsHelper . EnableThirdParty
2020-02-26 10:01:12 +00:00
& & ! CoreBaseSettings . Personal ) )
{
return result ;
}
2020-11-10 08:21:22 +00:00
return ThirdpartyConfiguration . GetProviders ( ) ;
2020-02-26 10:01:12 +00:00
}
/// <summary>
/// Saves the third party file storage service account
/// </summary>
/// <short>Save third party account</short>
/// <param name="url">Connection url for SharePoint</param>
/// <param name="login">Login</param>
/// <param name="password">Password</param>
/// <param name="token">Authentication token</param>
/// <param name="isCorporate"></param>
/// <param name="customerTitle">Title</param>
/// <param name="providerKey">Provider Key</param>
/// <param name="providerId">Provider ID</param>
/// <category>Third-Party Integration</category>
/// <returns>Folder contents</returns>
/// <remarks>List of provider key: DropboxV2, Box, WebDav, Yandex, OneDrive, SharePoint, GoogleDrive</remarks>
/// <exception cref="ArgumentException"></exception>
2020-11-10 10:41:32 +00:00
2021-11-22 13:17:27 +00:00
[Create("thirdparty")]
2021-12-27 17:52:40 +00:00
public Task < FolderWrapper < string > > SaveThirdPartyFromBodyAsync ( [ FromBody ] ThirdPartyModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return SaveThirdPartyAsync ( model ) ;
2021-11-22 13:17:27 +00:00
}
[Create("thirdparty")]
[Consumes("application/x-www-form-urlencoded")]
2021-12-27 17:52:40 +00:00
public Task < FolderWrapper < string > > SaveThirdPartyFromFormAsync ( [ FromForm ] ThirdPartyModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return SaveThirdPartyAsync ( model ) ;
2021-11-22 13:17:27 +00:00
}
private async Task < FolderWrapper < string > > SaveThirdPartyAsync ( ThirdPartyModel model )
{
var thirdPartyParams = new ThirdPartyParams
{
AuthData = new AuthData ( model . Url , model . Login , model . Password , model . Token ) ,
Corporate = model . IsCorporate ,
CustomerTitle = model . CustomerTitle ,
ProviderId = model . ProviderId ,
ProviderKey = model . ProviderKey ,
} ;
var folder = await FileStorageService . SaveThirdPartyAsync ( thirdPartyParams ) ;
return await FolderWrapperHelper . GetAsync ( folder ) ;
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Returns the list of all connected third party services
/// </summary>
/// <category>Third-Party Integration</category>
/// <short>Get third party list</short>
/// <returns>Connected providers</returns>
2021-11-22 13:17:27 +00:00
[Read("thirdparty")]
public async Task < IEnumerable < ThirdPartyParams > > GetThirdPartyAccountsAsync ( )
{
return await FileStorageService . GetThirdPartyAsync ( ) ;
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Returns the list of third party services connected in the 'Common Documents' section
/// </summary>
/// <category>Third-Party Integration</category>
/// <short>Get third party folder</short>
/// <returns>Connected providers folder</returns>
2021-11-22 13:17:27 +00:00
[Read("thirdparty/common")]
public async Task < IEnumerable < FolderWrapper < string > > > GetCommonThirdPartyFoldersAsync ( )
{
2022-01-18 16:50:31 +00:00
var parent = await FileStorageServiceInt . GetFolderAsync ( await GlobalFolderHelper . FolderCommonAsync ) ;
2021-11-22 13:17:27 +00:00
var thirdpartyFolders = await EntryManager . GetThirpartyFoldersAsync ( parent ) ;
2022-02-22 09:22:15 +00:00
var result = new List < FolderWrapper < string > > ( ) ;
foreach ( var r in thirdpartyFolders )
{
result . Add ( await FolderWrapperHelper . GetAsync ( r ) ) ;
}
return result ;
2021-11-22 13:17:27 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Removes the third party file storage service account with the ID specified in the request
/// </summary>
/// <param name="providerId">Provider ID. Provider id is part of folder id.
/// Example, folder id is "sbox-123", then provider id is "123"
/// </param>
/// <short>Remove third party account</short>
/// <category>Third-Party Integration</category>
/// <returns>Folder id</returns>
///<exception cref="ArgumentException"></exception>
2021-11-22 13:17:27 +00:00
[Delete("thirdparty/{providerId:int}")]
2021-12-27 17:52:40 +00:00
public Task < object > DeleteThirdPartyAsync ( int providerId )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FileStorageService . DeleteThirdPartyAsync ( providerId . ToString ( CultureInfo . InvariantCulture ) ) ;
2021-11-22 13:17:27 +00:00
}
2020-02-26 10:01:12 +00:00
///// <summary>
/////
///// </summary>
///// <param name="query"></param>
///// <returns></returns>
//[Read(@"@search/{query}")]
//public IEnumerable<FileEntryWrapper> Search(string query)
//{
// var searcher = new SearchHandler();
// var files = searcher.SearchFiles(query).Select(r => (FileEntryWrapper)FileWrapperHelper.Get(r));
// var folders = searcher.SearchFolders(query).Select(f => (FileEntryWrapper)FolderWrapperHelper.Get(f));
// return files.Concat(folders);
//}
2020-09-22 14:17:17 +00:00
/// <summary>
/// Adding files to favorite list
/// </summary>
/// <short>Favorite add</short>
/// <category>Files</category>
/// <param name="folderIds" visible="false"></param>
/// <param name="fileIds">File IDs</param>
/// <returns></returns>
2020-11-06 09:03:49 +00:00
2021-11-22 13:17:27 +00:00
[Create("favorites")]
2021-12-27 17:52:40 +00:00
public Task < bool > AddFavoritesFromBodyAsync ( [ FromBody ] BaseBatchModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return AddFavoritesAsync ( model ) ;
2021-11-22 13:17:27 +00:00
}
[Create("favorites")]
[Consumes("application/x-www-form-urlencoded")]
public async Task < bool > AddFavoritesFromFormAsync ( [ FromForm ] [ ModelBinder ( BinderType = typeof ( BaseBatchModelBinder ) ) ] BaseBatchModel model )
{
return await AddFavoritesAsync ( model ) ;
}
private async Task < bool > AddFavoritesAsync ( BaseBatchModel model )
{
var ( folderIntIds , folderStringIds ) = FileOperationsManager . GetIds ( model . FolderIds ) ;
var ( fileIntIds , fileStringIds ) = FileOperationsManager . GetIds ( model . FileIds ) ;
await FileStorageServiceInt . AddToFavoritesAsync ( folderIntIds , fileIntIds ) ;
await FileStorageService . AddToFavoritesAsync ( folderStringIds , fileStringIds ) ;
return true ;
}
[Read("favorites/{fileId}")]
2021-12-27 17:52:40 +00:00
public Task < bool > ToggleFileFavoriteAsync ( string fileId , bool favorite )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FileStorageService . ToggleFileFavoriteAsync ( fileId , favorite ) ;
2021-11-22 13:17:27 +00:00
}
[Read("favorites/{fileId:int}")]
2021-12-27 17:52:40 +00:00
public Task < bool > ToggleFavoriteFromFormAsync ( int fileId , bool favorite )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FileStorageServiceInt . ToggleFileFavoriteAsync ( fileId , favorite ) ;
2021-11-22 13:17:27 +00:00
}
2020-09-22 14:17:17 +00:00
/// <summary>
/// Removing files from favorite list
/// </summary>
/// <short>Favorite delete</short>
/// <category>Files</category>
/// <param name="folderIds" visible="false"></param>
/// <param name="fileIds">File IDs</param>
/// <returns></returns>
2021-10-04 17:37:28 +00:00
2021-11-22 13:17:27 +00:00
[Delete("favorites")]
[Consumes("application/json")]
2021-12-27 17:52:40 +00:00
public Task < bool > DeleteFavoritesFromBodyAsync ( [ FromBody ] BaseBatchModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return DeleteFavoritesAsync ( model ) ;
2021-11-22 13:17:27 +00:00
}
[Delete("favorites")]
public async Task < bool > DeleteFavoritesFromQueryAsync ( [ FromQuery ] [ ModelBinder ( BinderType = typeof ( BaseBatchModelBinder ) ) ] BaseBatchModel model )
{
return await DeleteFavoritesAsync ( model ) ;
}
private async Task < bool > DeleteFavoritesAsync ( BaseBatchModel model )
{
var ( folderIntIds , folderStringIds ) = FileOperationsManager . GetIds ( model . FolderIds ) ;
var ( fileIntIds , fileStringIds ) = FileOperationsManager . GetIds ( model . FileIds ) ;
await FileStorageServiceInt . DeleteFavoritesAsync ( folderIntIds , fileIntIds ) ;
await FileStorageService . DeleteFavoritesAsync ( folderStringIds , fileStringIds ) ;
return true ;
}
2020-09-22 14:17:17 +00:00
/// <summary>
/// Adding files to template list
/// </summary>
/// <short>Template add</short>
/// <category>Files</category>
/// <param name="fileIds">File IDs</param>
/// <returns></returns>
2020-11-10 10:41:32 +00:00
2021-11-22 13:17:27 +00:00
[Create("templates")]
public async Task < bool > AddTemplatesFromBodyAsync ( [ FromBody ] TemplatesModel model )
{
await FileStorageServiceInt . AddToTemplatesAsync ( model . FileIds ) ;
return true ;
}
[Create("templates")]
[Consumes("application/x-www-form-urlencoded")]
public async Task < bool > AddTemplatesFromFormAsync ( [ FromForm ] TemplatesModel model )
{
await FileStorageServiceInt . AddToTemplatesAsync ( model . FileIds ) ;
return true ;
}
2020-09-22 14:17:17 +00:00
/// <summary>
/// Removing files from template list
/// </summary>
/// <short>Template delete</short>
/// <category>Files</category>
/// <param name="fileIds">File IDs</param>
/// <returns></returns>
2020-02-26 10:01:12 +00:00
2021-11-22 13:17:27 +00:00
[Delete("templates")]
public async Task < bool > DeleteTemplatesAsync ( IEnumerable < int > fileIds )
{
await FileStorageServiceInt . DeleteTemplatesAsync ( fileIds ) ;
return true ;
}
2020-02-26 10:01:12 +00:00
/// <summary>
///
/// </summary>
/// <param name="set"></param>
/// <returns></returns>
[Update(@"storeoriginal")]
2021-07-09 15:41:07 +00:00
public bool StoreOriginalFromBody ( [ FromBody ] SettingsModel model )
2020-11-11 15:36:58 +00:00
{
return FileStorageService . StoreOriginal ( model . Set ) ;
}
[Update(@"storeoriginal")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public bool StoreOriginalFromForm ( [ FromForm ] SettingsModel model )
2020-02-26 10:01:12 +00:00
{
2020-08-27 15:05:21 +00:00
return FileStorageService . StoreOriginal ( model . Set ) ;
2020-02-26 10:01:12 +00:00
}
2020-08-31 12:41:28 +00:00
/// <summary>
///
/// </summary>
/// <returns></returns>
[Read(@"settings")]
2021-06-11 11:33:07 +00:00
public FilesSettingsHelper GetFilesSettings ( )
2020-08-31 12:41:28 +00:00
{
2021-06-11 11:33:07 +00:00
return FilesSettingsHelper ;
2020-08-31 12:41:28 +00:00
}
2020-02-26 10:01:12 +00:00
/// <summary>
///
/// </summary>
/// <param name="save"></param>
/// <visible>false</visible>
/// <returns></returns>
[Update(@"hideconfirmconvert")]
2021-07-09 15:41:07 +00:00
public bool HideConfirmConvertFromBody ( [ FromBody ] HideConfirmConvertModel model )
2020-02-26 10:01:12 +00:00
{
2020-11-11 15:36:58 +00:00
return FileStorageService . HideConfirmConvert ( model . Save ) ;
2020-02-26 10:01:12 +00:00
}
2020-11-11 15:36:58 +00:00
[Update(@"hideconfirmconvert")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public bool HideConfirmConvertFromForm ( [ FromForm ] HideConfirmConvertModel model )
2020-11-11 15:36:58 +00:00
{
return FileStorageService . HideConfirmConvert ( model . Save ) ;
}
2020-08-27 15:05:21 +00:00
2020-02-26 10:01:12 +00:00
/// <summary>
///
/// </summary>
/// <param name="set"></param>
/// <returns></returns>
[Update(@"updateifexist")]
2021-07-09 15:41:07 +00:00
public bool UpdateIfExistFromBody ( [ FromBody ] SettingsModel model )
2020-11-11 15:36:58 +00:00
{
return FileStorageService . UpdateIfExist ( model . Set ) ;
}
[Update(@"updateifexist")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public bool UpdateIfExistFromForm ( [ FromForm ] SettingsModel model )
2020-08-27 15:05:21 +00:00
{
return FileStorageService . UpdateIfExist ( model . Set ) ;
}
/// <summary>
///
/// </summary>
/// <param name="set"></param>
/// <returns></returns>
[Update(@"changedeleteconfrim")]
2021-07-09 15:41:07 +00:00
public bool ChangeDeleteConfrimFromBody ( [ FromBody ] SettingsModel model )
2020-11-11 15:36:58 +00:00
{
return FileStorageService . ChangeDeleteConfrim ( model . Set ) ;
}
[Update(@"changedeleteconfrim")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public bool ChangeDeleteConfrimFromForm ( [ FromForm ] SettingsModel model )
2020-08-27 15:05:21 +00:00
{
2020-08-31 12:41:28 +00:00
return FileStorageService . ChangeDeleteConfrim ( model . Set ) ;
2020-08-27 15:05:21 +00:00
}
/// <summary>
///
/// </summary>
/// <param name="set"></param>
/// <returns></returns>
[Update(@"storeforcesave")]
2021-07-09 15:41:07 +00:00
public bool StoreForcesaveFromBody ( [ FromBody ] SettingsModel model )
2020-11-11 15:36:58 +00:00
{
return FileStorageService . StoreForcesave ( model . Set ) ;
}
[Update(@"storeforcesave")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public bool StoreForcesaveFromForm ( [ FromForm ] SettingsModel model )
2020-02-26 10:01:12 +00:00
{
2020-08-27 15:05:21 +00:00
return FileStorageService . StoreForcesave ( model . Set ) ;
2020-02-26 10:01:12 +00:00
}
2020-08-31 12:41:28 +00:00
/// <summary>
///
/// </summary>
/// <param name="set"></param>
/// <returns></returns>
[Update(@"forcesave")]
2021-07-09 15:41:07 +00:00
public bool ForcesaveFromBody ( [ FromBody ] SettingsModel model )
2020-11-11 15:36:58 +00:00
{
return FileStorageService . Forcesave ( model . Set ) ;
}
[Update(@"forcesave")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public bool ForcesaveFromForm ( [ FromForm ] SettingsModel model )
2020-08-31 12:41:28 +00:00
{
return FileStorageService . Forcesave ( model . Set ) ;
}
/// <summary>
///
/// </summary>
/// <param name="set"></param>
/// <returns></returns>
[Update(@"thirdparty")]
2021-07-09 15:41:07 +00:00
public bool ChangeAccessToThirdpartyFromBody ( [ FromBody ] SettingsModel model )
2020-11-11 15:36:58 +00:00
{
return FileStorageService . ChangeAccessToThirdparty ( model . Set ) ;
}
[Update(@"thirdparty")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public bool ChangeAccessToThirdpartyFromForm ( [ FromForm ] SettingsModel model )
2020-08-31 12:41:28 +00:00
{
return FileStorageService . ChangeAccessToThirdparty ( model . Set ) ;
}
2020-09-22 14:17:17 +00:00
/// <summary>
/// Display recent folder
/// </summary>
/// <param name="set"></param>
/// <category>Settings</category>
/// <returns></returns>
[Update(@"displayRecent")]
2021-07-09 15:41:07 +00:00
public bool DisplayRecentFromBody ( [ FromBody ] DisplayModel model )
2020-09-22 14:17:17 +00:00
{
2020-11-11 15:36:58 +00:00
return FileStorageService . DisplayRecent ( model . Set ) ;
}
[Update(@"displayRecent")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public bool DisplayRecentFromForm ( [ FromForm ] DisplayModel model )
2020-11-11 15:36:58 +00:00
{
return FileStorageService . DisplayRecent ( model . Set ) ;
2020-09-22 14:17:17 +00:00
}
/// <summary>
/// Display favorite folder
/// </summary>
/// <param name="set"></param>
/// <category>Settings</category>
/// <returns></returns>
[Update(@"settings/favorites")]
2021-07-09 15:41:07 +00:00
public bool DisplayFavoriteFromBody ( [ FromBody ] DisplayModel model )
2020-09-22 14:17:17 +00:00
{
2020-11-11 15:36:58 +00:00
return FileStorageService . DisplayFavorite ( model . Set ) ;
}
[Update(@"settings/favorites")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public bool DisplayFavoriteFromForm ( [ FromForm ] DisplayModel model )
2020-09-22 14:17:17 +00:00
{
2020-11-11 15:36:58 +00:00
return FileStorageService . DisplayFavorite ( model . Set ) ;
2020-09-22 14:17:17 +00:00
}
/// <summary>
/// Display template folder
/// </summary>
/// <param name="set"></param>
/// <category>Settings</category>
/// <returns></returns>
[Update(@"settings/templates")]
2021-07-09 15:41:07 +00:00
public bool DisplayTemplatesFromBody ( [ FromBody ] DisplayModel model )
2020-09-22 14:17:17 +00:00
{
2020-11-11 15:36:58 +00:00
return FileStorageService . DisplayTemplates ( model . Set ) ;
}
[Update(@"settings/templates")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public bool DisplayTemplatesFromForm ( [ FromForm ] DisplayModel model )
2020-09-22 14:17:17 +00:00
{
2020-11-11 15:36:58 +00:00
return FileStorageService . DisplayTemplates ( model . Set ) ;
2020-09-22 14:17:17 +00:00
}
2021-05-23 16:11:25 +00:00
/// <summary>
///
/// </summary>
/// <param name="set"></param>
/// <category>Settings</category>
/// <returns></returns>
[Update(@"settings/downloadtargz")]
2021-11-16 17:40:15 +00:00
public ICompress ChangeDownloadZipFromBody ( [ FromBody ] DisplayModel model )
2021-05-23 16:11:25 +00:00
{
return FileStorageService . ChangeDownloadTarGz ( model . Set ) ;
}
[Update(@"settings/downloadtargz")]
2021-11-16 17:40:15 +00:00
public ICompress ChangeDownloadZipFromForm ( [ FromForm ] DisplayModel model )
2021-05-23 16:11:25 +00:00
{
return FileStorageService . ChangeDownloadTarGz ( model . Set ) ;
}
2020-02-26 10:01:12 +00:00
/// <summary>
/// Checking document service location
/// </summary>
/// <param name="docServiceUrl">Document editing service Domain</param>
/// <param name="docServiceUrlInternal">Document command service Domain</param>
/// <param name="docServiceUrlPortal">Community Server Address</param>
/// <returns></returns>
[Update("docservice")]
2022-01-25 09:29:11 +00:00
public Task < IEnumerable < string > > CheckDocServiceUrlFromBodyAsync ( [ FromBody ] CheckDocServiceUrlModel model )
2020-02-26 10:01:12 +00:00
{
2022-01-25 09:29:11 +00:00
return CheckDocServiceUrlAsync ( model ) ;
2020-11-10 10:41:32 +00:00
}
[Update("docservice")]
[Consumes("application/x-www-form-urlencoded")]
2022-01-25 09:29:11 +00:00
public Task < IEnumerable < string > > CheckDocServiceUrlFromFormAsync ( [ FromForm ] CheckDocServiceUrlModel model )
2020-11-10 10:41:32 +00:00
{
2022-01-25 09:29:11 +00:00
return CheckDocServiceUrlAsync ( model ) ;
2020-11-10 10:41:32 +00:00
}
2021-05-23 16:11:25 +00:00
/// <summary>
/// Create thumbnails for files with the IDs specified in the request
/// </summary>
/// <short>Create thumbnails</short>
/// <category>Files</category>
/// <param name="fileIds">File IDs</param>
/// <visible>false</visible>
/// <returns></returns>
2021-11-22 13:17:27 +00:00
[Create("thumbnails")]
2021-12-27 17:52:40 +00:00
public Task < IEnumerable < JsonElement > > CreateThumbnailsFromBodyAsync ( [ FromBody ] BaseBatchModel model )
2021-11-22 13:17:27 +00:00
{
2021-12-27 17:52:40 +00:00
return FileStorageService . CreateThumbnailsAsync ( model . FileIds . ToList ( ) ) ;
2021-11-22 13:17:27 +00:00
}
[Create("thumbnails")]
[Consumes("application/x-www-form-urlencoded")]
public async Task < IEnumerable < JsonElement > > CreateThumbnailsFromFormAsync ( [ FromForm ] [ ModelBinder ( BinderType = typeof ( BaseBatchModelBinder ) ) ] BaseBatchModel model )
{
return await FileStorageService . CreateThumbnailsAsync ( model . FileIds . ToList ( ) ) ;
}
2021-11-16 17:40:15 +00:00
[Create("masterform/{fileId}/checkfillformdraft")]
2022-01-12 19:07:21 +00:00
public async Task < object > CheckFillFormDraftFromBodyAsync ( string fileId , [ FromBody ] CheckFillFormDraftModel model )
2021-11-16 17:40:15 +00:00
{
2022-01-12 19:07:21 +00:00
return await FilesControllerHelperString . CheckFillFormDraftAsync ( fileId , model . Version , model . Doc , ! model . RequestEmbedded , model . RequestView ) ;
2021-11-16 17:40:15 +00:00
}
[Create("masterform/{fileId}/checkfillformdraft")]
[Consumes("application/x-www-form-urlencoded")]
2022-01-12 19:07:21 +00:00
public async Task < object > CheckFillFormDraftFromFormAsync ( string fileId , [ FromForm ] CheckFillFormDraftModel model )
2021-11-16 17:40:15 +00:00
{
2022-01-12 19:07:21 +00:00
return await FilesControllerHelperString . CheckFillFormDraftAsync ( fileId , model . Version , model . Doc , ! model . RequestEmbedded , model . RequestView ) ;
2021-11-16 17:40:15 +00:00
}
[Create("masterform/{fileId:int}/checkfillformdraft")]
2022-01-12 19:07:21 +00:00
public async Task < object > CheckFillFormDraftFromBodyAsync ( int fileId , [ FromBody ] CheckFillFormDraftModel model )
2021-11-16 17:40:15 +00:00
{
2022-01-12 19:07:21 +00:00
return await FilesControllerHelperInt . CheckFillFormDraftAsync ( fileId , model . Version , model . Doc , ! model . RequestEmbedded , model . RequestView ) ;
2021-11-16 17:40:15 +00:00
}
[Create("masterform/{fileId:int}/checkfillformdraft")]
[Consumes("application/x-www-form-urlencoded")]
2022-01-12 19:07:21 +00:00
public async Task < object > CheckFillFormDraftFromFormAsync ( int fileId , [ FromForm ] CheckFillFormDraftModel model )
2021-11-16 17:40:15 +00:00
{
2022-01-12 19:07:21 +00:00
return await FilesControllerHelperInt . CheckFillFormDraftAsync ( fileId , model . Version , model . Doc , ! model . RequestEmbedded , model . RequestView ) ;
2021-11-16 17:40:15 +00:00
}
2022-02-16 12:57:37 +00:00
public Task < IEnumerable < string > > CheckDocServiceUrlAsync ( CheckDocServiceUrlModel model )
2020-02-26 10:01:12 +00:00
{
2020-11-10 10:41:32 +00:00
FilesLinkUtility . DocServiceUrl = model . DocServiceUrl ;
FilesLinkUtility . DocServiceUrlInternal = model . DocServiceUrlInternal ;
FilesLinkUtility . DocServicePortalUrl = model . DocServiceUrlPortal ;
2020-02-26 10:01:12 +00:00
MessageService . Send ( MessageAction . DocumentServiceLocationSetting ) ;
var https = new Regex ( @"^https://" , RegexOptions . IgnoreCase ) ;
var http = new Regex ( @"^http://" , RegexOptions . IgnoreCase ) ;
if ( https . IsMatch ( CommonLinkUtility . GetFullAbsolutePath ( "" ) ) & & http . IsMatch ( FilesLinkUtility . DocServiceUrl ) )
{
throw new Exception ( "Mixed Active Content is not allowed. HTTPS address for Document Server is required." ) ;
}
2022-02-16 12:57:37 +00:00
return InternalCheckDocServiceUrlAsync ( ) ;
}
private async Task < IEnumerable < string > > InternalCheckDocServiceUrlAsync ( )
{
2022-01-25 09:29:11 +00:00
await DocumentServiceConnector . CheckDocServiceUrlAsync ( ) ;
2020-02-26 10:01:12 +00:00
return new [ ]
{
FilesLinkUtility . DocServiceUrl ,
FilesLinkUtility . DocServiceUrlInternal ,
FilesLinkUtility . DocServicePortalUrl
} ;
}
/// <visible>false</visible>
2020-12-10 16:15:36 +00:00
[AllowAnonymous]
2020-02-26 10:01:12 +00:00
[Read("docservice")]
2022-02-16 12:57:37 +00:00
public Task < object > GetDocServiceUrlAsync ( bool version )
2020-02-26 10:01:12 +00:00
{
var url = CommonLinkUtility . GetFullAbsolutePath ( FilesLinkUtility . DocServiceApiUrl ) ;
if ( ! version )
{
2022-02-16 12:57:37 +00:00
return Task . FromResult < object > ( url ) ;
2020-02-26 10:01:12 +00:00
}
2022-02-16 12:57:37 +00:00
return InternalGetDocServiceUrlAsync ( url ) ;
}
private async Task < object > InternalGetDocServiceUrlAsync ( string url )
{
2022-01-31 14:35:36 +00:00
var dsVersion = await DocumentServiceConnector . GetVersionAsync ( ) ;
2020-02-26 10:01:12 +00:00
return new
{
version = dsVersion ,
docServiceUrlApi = url ,
} ;
}
#region wordpress
/// <visible>false</visible>
[Read("wordpress-info")]
public object GetWordpressInfo ( )
{
var token = WordpressToken . GetToken ( ) ;
if ( token ! = null )
{
var meInfo = WordpressHelper . GetWordpressMeInfo ( token . AccessToken ) ;
var blogId = JObject . Parse ( meInfo ) . Value < string > ( "token_site_id" ) ;
var wordpressUserName = JObject . Parse ( meInfo ) . Value < string > ( "username" ) ;
var blogInfo = RequestHelper . PerformRequest ( WordpressLoginProvider . WordpressSites + blogId , "" , "GET" , "" ) ;
var jsonBlogInfo = JObject . Parse ( blogInfo ) ;
jsonBlogInfo . Add ( "username" , wordpressUserName ) ;
blogInfo = jsonBlogInfo . ToString ( ) ;
return new
{
success = true ,
data = blogInfo
} ;
}
return new
{
success = false
} ;
}
/// <visible>false</visible>
[Read("wordpress-delete")]
public object DeleteWordpressInfo ( )
{
var token = WordpressToken . GetToken ( ) ;
if ( token ! = null )
{
WordpressToken . DeleteToken ( token ) ;
return new
{
success = true
} ;
}
return new
{
success = false
} ;
}
/// <visible>false</visible>
[Create("wordpress-save")]
2021-07-09 15:41:07 +00:00
public object WordpressSaveFromBody ( [ FromBody ] WordpressSaveModel model )
2020-02-26 10:01:12 +00:00
{
2020-11-10 10:41:32 +00:00
return WordpressSave ( model ) ;
}
[Create("wordpress-save")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public object WordpressSaveFromForm ( [ FromForm ] WordpressSaveModel model )
2020-11-10 10:41:32 +00:00
{
return WordpressSave ( model ) ;
}
private object WordpressSave ( WordpressSaveModel model )
{
2022-01-12 15:42:03 +00:00
if ( model . Code . Length = = 0 )
2020-02-26 10:01:12 +00:00
{
return new
{
success = false
} ;
}
try
{
2020-11-10 11:51:33 +00:00
var token = WordpressToken . SaveTokenFromCode ( model . Code ) ;
2020-02-26 10:01:12 +00:00
var meInfo = WordpressHelper . GetWordpressMeInfo ( token . AccessToken ) ;
var blogId = JObject . Parse ( meInfo ) . Value < string > ( "token_site_id" ) ;
var wordpressUserName = JObject . Parse ( meInfo ) . Value < string > ( "username" ) ;
var blogInfo = RequestHelper . PerformRequest ( WordpressLoginProvider . WordpressSites + blogId , "" , "GET" , "" ) ;
var jsonBlogInfo = JObject . Parse ( blogInfo ) ;
jsonBlogInfo . Add ( "username" , wordpressUserName ) ;
blogInfo = jsonBlogInfo . ToString ( ) ;
return new
{
success = true ,
data = blogInfo
} ;
}
catch ( Exception )
{
return new
{
success = false
} ;
}
}
/// <visible>false</visible>
[Create("wordpress")]
2021-07-09 15:41:07 +00:00
public bool CreateWordpressPostFromBody ( [ FromBody ] CreateWordpressPostModel model )
2020-11-10 10:41:32 +00:00
{
return CreateWordpressPost ( model ) ;
}
[Create("wordpress")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public bool CreateWordpressPostFromForm ( [ FromForm ] CreateWordpressPostModel model )
2020-11-10 10:41:32 +00:00
{
return CreateWordpressPost ( model ) ;
}
private bool CreateWordpressPost ( CreateWordpressPostModel model )
2020-02-26 10:01:12 +00:00
{
try
{
var token = WordpressToken . GetToken ( ) ;
var meInfo = WordpressHelper . GetWordpressMeInfo ( token . AccessToken ) ;
var parser = JObject . Parse ( meInfo ) ;
if ( parser = = null ) return false ;
var blogId = parser . Value < string > ( "token_site_id" ) ;
if ( blogId ! = null )
{
2020-11-10 10:41:32 +00:00
var createPost = WordpressHelper . CreateWordpressPost ( model . Title , model . Content , model . Status , blogId , token ) ;
2020-02-26 10:01:12 +00:00
return createPost ;
}
return false ;
}
catch ( Exception )
{
return false ;
}
}
#endregion
#region easybib
/// <visible>false</visible>
[Read("easybib-citation-list")]
public object GetEasybibCitationList ( int source , string data )
{
try
{
var citationList = EasyBibHelper . GetEasyBibCitationsList ( source , data ) ;
return new
{
success = true ,
citations = citationList
} ;
}
catch ( Exception )
{
return new
{
success = false
} ;
}
}
/// <visible>false</visible>
[Read("easybib-styles")]
public object GetEasybibStyles ( )
{
try
{
var data = EasyBibHelper . GetEasyBibStyles ( ) ;
return new
{
success = true ,
styles = data
} ;
}
catch ( Exception )
{
return new
{
success = false
} ;
}
}
/// <visible>false</visible>
[Create("easybib-citation")]
2021-07-09 15:41:07 +00:00
public object EasyBibCitationBookFromBody ( [ FromBody ] EasyBibCitationBookModel model )
2020-11-10 10:41:32 +00:00
{
return EasyBibCitationBook ( model ) ;
}
[Create("easybib-citation")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public object EasyBibCitationBookFromForm ( [ FromForm ] EasyBibCitationBookModel model )
2020-11-10 10:41:32 +00:00
{
return EasyBibCitationBook ( model ) ;
}
private object EasyBibCitationBook ( EasyBibCitationBookModel model )
2020-02-26 10:01:12 +00:00
{
try
{
2020-11-10 10:41:32 +00:00
var citat = EasyBibHelper . GetEasyBibCitation ( model . CitationData ) ;
2020-02-26 10:01:12 +00:00
if ( citat ! = null )
{
return new
{
success = true ,
citation = citat
} ;
}
else
{
return new
{
success = false
} ;
}
}
catch ( Exception )
{
return new
{
success = false
} ;
}
}
#endregion
/// <summary>
/// Result of file conversation operation.
/// </summary>
2020-03-18 13:19:37 +00:00
public class ConversationResult < T >
2020-02-26 10:01:12 +00:00
{
/// <summary>
/// Operation Id.
/// </summary>
public string Id { get ; set ; }
/// <summary>
/// Operation type.
/// </summary>
2020-07-09 09:02:44 +00:00
[JsonPropertyName("Operation")]
2020-02-26 10:01:12 +00:00
public FileOperationType OperationType { get ; set ; }
/// <summary>
/// Operation progress.
/// </summary>
public int Progress { get ; set ; }
/// <summary>
/// Source files for operation.
/// </summary>
public string Source { get ; set ; }
/// <summary>
/// Result file of operation.
/// </summary>
2020-07-09 09:02:44 +00:00
[JsonPropertyName("result")]
2021-12-08 17:17:50 +00:00
public object File { get ; set ; }
2020-02-26 10:01:12 +00:00
/// <summary>
/// Error during conversation.
/// </summary>
public string Error { get ; set ; }
/// <summary>
/// Is operation processed.
/// </summary>
public string Processed { get ; set ; }
}
}
}