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 ;
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.Http ;
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")]
public IEnumerable < FolderContentWrapper < int > > GetRootFolders ( Guid userIdOrGroupId , FilterType filterType , bool withsubfolders , bool withoutTrash , bool withoutAdditionalFolder )
{
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 ) ;
2020-10-22 14:17:20 +00:00
var result = new SortedSet < int > ( ) ;
2021-05-06 10:27:15 +00:00
if ( IsOutsider )
{
withoutTrash = true ;
withoutAdditionalFolder = true ;
}
2020-10-22 14:17:20 +00:00
if ( ! IsVisitor )
{
result . Add ( GlobalFolderHelper . FolderMy ) ;
}
if ( ! CoreBaseSettings . Personal & & ! UserManager . GetUsers ( SecurityContext . CurrentAccount . ID ) . IsOutsider ( UserManager ) )
{
result . Add ( GlobalFolderHelper . FolderShare ) ;
}
if ( ! IsVisitor & & ! withoutAdditionalFolder )
{
if ( FilesSettingsHelper . FavoritesSection )
{
result . Add ( GlobalFolderHelper . FolderFavorites ) ;
}
if ( FilesSettingsHelper . RecentSection )
{
result . Add ( GlobalFolderHelper . FolderRecent ) ;
}
2021-07-09 15:41:07 +00:00
if ( ! CoreBaseSettings . Personal & & PrivacyRoomSettings . IsAvailable ( TenantManager ) )
2020-10-22 14:17:20 +00:00
{
result . Add ( GlobalFolderHelper . FolderPrivacy ) ;
}
}
if ( ! CoreBaseSettings . Personal )
{
result . Add ( GlobalFolderHelper . FolderCommon ) ;
}
if ( ! IsVisitor
& & ! withoutAdditionalFolder
& & FileUtility . ExtsWebTemplate . Any ( )
& & FilesSettingsHelper . TemplatesSection )
{
result . Add ( GlobalFolderHelper . FolderTemplates ) ;
}
2021-05-06 10:27:15 +00:00
if ( ! withoutTrash )
2020-10-22 14:17:20 +00:00
{
result . Add ( ( int ) GlobalFolderHelper . FolderTrash ) ;
}
2021-04-13 09:46:25 +00:00
return result . Select ( r = > FilesControllerHelperInt . GetFolder ( r , userIdOrGroupId , filterType , withsubfolders ) ) . ToList ( ) ;
2020-10-22 14:17:20 +00:00
}
2020-11-02 08:29:01 +00:00
[Read("@privacy")]
public FolderContentWrapper < int > GetPrivacyFolder ( Guid userIdOrGroupId , FilterType filterType , bool withsubfolders )
{
if ( ! IsAvailablePrivacyRoomSettings ( ) ) throw new System . Security . SecurityException ( ) ;
return FilesControllerHelperInt . GetFolder ( GlobalFolderHelper . FolderPrivacy , userIdOrGroupId , filterType , withsubfolders ) ;
}
[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")]
2020-03-19 13:18:35 +00:00
public FolderContentWrapper < int > GetMyFolder ( Guid userIdOrGroupId , FilterType filterType , bool withsubfolders )
2020-02-26 10:01:12 +00:00
{
2020-06-13 15:31:45 +00:00
return FilesControllerHelperInt . GetFolder ( GlobalFolderHelper . FolderMy , userIdOrGroupId , filterType , withsubfolders ) ;
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")]
2020-04-02 11:21:05 +00:00
public FolderContentWrapper < string > GetProjectsFolder ( Guid userIdOrGroupId , FilterType filterType , bool withsubfolders )
2020-02-26 10:01:12 +00:00
{
2020-06-13 15:31:45 +00:00
return FilesControllerHelperString . GetFolder ( GlobalFolderHelper . GetFolderProjects < string > ( ) , userIdOrGroupId , filterType , withsubfolders ) ;
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")]
2020-03-19 13:07:16 +00:00
public FolderContentWrapper < int > GetCommonFolder ( Guid userIdOrGroupId , FilterType filterType , bool withsubfolders )
2020-02-26 10:01:12 +00:00
{
2020-06-13 15:31:45 +00:00
return FilesControllerHelperInt . GetFolder ( GlobalFolderHelper . FolderCommon , userIdOrGroupId , filterType , withsubfolders ) ;
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")]
2020-03-19 13:18:35 +00:00
public FolderContentWrapper < int > GetShareFolder ( Guid userIdOrGroupId , FilterType filterType , bool withsubfolders )
2020-02-26 10:01:12 +00:00
{
2020-06-13 15:31:45 +00:00
return FilesControllerHelperInt . GetFolder ( GlobalFolderHelper . FolderShare , userIdOrGroupId , filterType , withsubfolders ) ;
2020-02-26 10:01:12 +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>
[Read("@recent")]
public FolderContentWrapper < int > GetRecentFolder ( Guid userIdOrGroupId , FilterType filterType , bool withsubfolders )
{
return FilesControllerHelperInt . GetFolder ( GlobalFolderHelper . FolderRecent , userIdOrGroupId , filterType , withsubfolders ) ;
}
2020-10-07 14:31:17 +00:00
[Create("file/{fileId}/recent", order: int.MaxValue)]
public FileWrapper < string > AddToRecent ( string fileId )
{
return FilesControllerHelperString . AddToRecent ( fileId ) ;
}
[Create("file/{fileId:int}/recent", order: int.MaxValue - 1)]
public FileWrapper < int > AddToRecent ( int fileId )
{
return FilesControllerHelperInt . AddToRecent ( fileId ) ;
}
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")]
public FolderContentWrapper < int > GetFavoritesFolder ( Guid userIdOrGroupId , FilterType filterType , bool withsubfolders )
{
return FilesControllerHelperInt . GetFolder ( GlobalFolderHelper . FolderFavorites , userIdOrGroupId , filterType , withsubfolders ) ;
}
/// <summary>
/// Returns the detailed list of templates files
/// </summary>
/// <short>Section Template</short>
/// <category>Folders</category>
/// <returns>Templates contents</returns>
[Read("@templates")]
public FolderContentWrapper < int > GetTemplatesFolder ( Guid userIdOrGroupId , FilterType filterType , bool withsubfolders )
{
return FilesControllerHelperInt . GetFolder ( GlobalFolderHelper . FolderTemplates , userIdOrGroupId , filterType , withsubfolders ) ;
}
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")]
2020-03-19 13:07:16 +00:00
public FolderContentWrapper < int > GetTrashFolder ( Guid userIdOrGroupId , FilterType filterType , bool withsubfolders )
2020-02-26 10:01:12 +00:00
{
2020-06-13 15:31:45 +00:00
return FilesControllerHelperInt . GetFolder ( Convert . ToInt32 ( GlobalFolderHelper . FolderTrash ) , userIdOrGroupId , filterType , withsubfolders ) ;
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>
2020-04-02 12:05:53 +00:00
[Read("{folderId}", order: int.MaxValue, DisableFormat = true)]
2020-03-19 13:18:35 +00:00
public FolderContentWrapper < string > GetFolder ( string folderId , Guid userIdOrGroupId , FilterType filterType , bool withsubfolders )
2020-02-26 10:01:12 +00:00
{
2020-03-19 13:18:35 +00:00
return FilesControllerHelperString . GetFolder ( folderId , userIdOrGroupId , filterType , withsubfolders ) . NotFoundIfNull ( ) ;
2020-02-28 11:32:11 +00:00
}
2020-02-26 10:01:12 +00:00
2021-09-30 18:26:01 +00:00
[Read("{folderId:int}", order: int.MaxValue - 1, DisableFormat = true)]
2020-03-19 13:18:35 +00:00
public FolderContentWrapper < int > GetFolder ( int folderId , Guid userIdOrGroupId , FilterType filterType , bool withsubfolders )
2020-02-28 11:32:11 +00:00
{
2020-03-19 13:18:35 +00:00
return FilesControllerHelperInt . GetFolder ( folderId , userIdOrGroupId , filterType , withsubfolders ) ;
2020-02-26 10:01:12 +00:00
}
2021-06-11 11:24:01 +00:00
[Read("{folderId}/subfolders")]
public IEnumerable < FileEntryWrapper > GetFolders ( string folderId )
{
return FilesControllerHelperString . GetFolders ( folderId ) ;
}
[Read("{folderId:int}/subfolders")]
public IEnumerable < FileEntryWrapper > GetFolders ( int folderId )
{
return FilesControllerHelperInt . GetFolders ( folderId ) ;
}
2020-06-25 17:17:24 +00:00
[Read("{folderId}/news")]
public List < FileEntryWrapper > GetNewItems ( string folderId )
{
return FilesControllerHelperString . GetNewItems ( folderId ) ;
}
[Read("{folderId:int}/news")]
public List < FileEntryWrapper > GetNewItems ( int folderId )
{
return FilesControllerHelperInt . GetNewItems ( folderId ) ;
}
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")]
2021-10-06 12:32:03 +00:00
public object UploadFileToMy ( [ ModelBinder ( BinderType = typeof ( UploadModelBinder ) ) ] UploadModel uploadModel )
2020-02-26 10:01:12 +00:00
{
uploadModel . CreateNewIfExist = false ;
2020-11-06 09:03:49 +00:00
return FilesControllerHelperInt . UploadFile ( 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-10-06 12:32:03 +00:00
public object UploadFileToCommon ( [ ModelBinder ( BinderType = typeof ( UploadModelBinder ) ) ] UploadModel uploadModel )
2020-11-06 09:03:49 +00:00
{
uploadModel . CreateNewIfExist = false ;
return FilesControllerHelperInt . UploadFile ( GlobalFolderHelper . FolderCommon , 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 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)]
2021-10-06 12:32:03 +00:00
public object UploadFile ( string folderId , [ ModelBinder ( BinderType = typeof ( UploadModelBinder ) ) ] UploadModel uploadModel )
2020-02-26 10:01:12 +00:00
{
2020-03-18 13:19:37 +00:00
return FilesControllerHelperString . UploadFile ( folderId , uploadModel ) ;
}
2020-02-26 10:01:12 +00:00
2021-09-27 19:28:49 +00:00
[Create("{folderId:int}/upload", order: int.MaxValue - 1)]
2021-10-06 12:32:03 +00:00
public object UploadFile ( int folderId , [ ModelBinder ( BinderType = typeof ( UploadModelBinder ) ) ] UploadModel uploadModel )
2020-03-18 13:19:37 +00:00
{
return FilesControllerHelperInt . UploadFile ( 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")]
2021-10-01 11:01:44 +00:00
public FileWrapper < int > InsertFileToMyFromBody ( [ FromForm ] [ ModelBinder ( BinderType = typeof ( InsertFileModelBinder ) ) ] InsertFileModel model )
2020-02-26 10:01:12 +00:00
{
2020-11-10 10:41:32 +00:00
return InsertFile ( GlobalFolderHelper . FolderMy , model ) ;
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-10-01 11:01:44 +00:00
public FileWrapper < int > InsertFileToCommonFromBody ( [ FromForm ] [ ModelBinder ( BinderType = typeof ( InsertFileModelBinder ) ) ] InsertFileModel model )
2020-11-10 10:41:32 +00:00
{
return InsertFile ( GlobalFolderHelper . FolderCommon , model ) ;
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)]
2021-10-01 11:01:44 +00:00
public FileWrapper < string > InsertFile ( string folderId , [ FromForm ] [ ModelBinder ( BinderType = typeof ( InsertFileModelBinder ) ) ] InsertFileModel model )
2020-11-10 10:41:32 +00:00
{
2021-10-01 11:01:44 +00:00
return FilesControllerHelperString . InsertFile ( 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)]
2021-10-01 11:01:44 +00:00
public FileWrapper < int > InsertFileFromForm ( int folderId , [ FromForm ] [ ModelBinder ( BinderType = typeof ( InsertFileModelBinder ) ) ] InsertFileModel model )
2020-11-10 10:41:32 +00:00
{
return InsertFile ( folderId , model ) ;
}
private FileWrapper < int > InsertFile ( int folderId , InsertFileModel model )
{
2021-10-01 11:01:44 +00:00
return FilesControllerHelperInt . InsertFile ( 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")]
2021-07-09 15:41:07 +00:00
public FileWrapper < string > UpdateFileStreamFromForm ( string fileId , [ FromForm ] FileStreamModel model )
2020-11-10 10:41:32 +00:00
{
2021-12-03 15:28:20 +00:00
return FilesControllerHelperString . UpdateFileStream ( FilesControllerHelperInt . GetFileFromRequest ( model ) . OpenReadStream ( ) , fileId , model . FileExtension , model . Encrypted , model . Forcesave ) ;
2020-11-10 10:41:32 +00:00
}
[Update("{fileId:int}/update")]
2021-07-09 15:41:07 +00:00
public FileWrapper < int > UpdateFileStreamFromForm ( int fileId , [ FromForm ] FileStreamModel model )
2020-11-10 10:41:32 +00:00
{
2021-12-03 15:28:20 +00:00
return FilesControllerHelperInt . UpdateFileStream ( 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")]
2021-07-09 15:41:07 +00:00
public FileWrapper < string > SaveEditingFromForm ( string fileId , [ FromForm ] SaveEditingModel model )
2020-02-26 10:01:12 +00:00
{
2021-09-29 16:08:30 +00:00
using var stream = FilesControllerHelperInt . GetFileFromRequest ( model ) . OpenReadStream ( ) ;
2021-03-01 11:38:55 +00:00
return FilesControllerHelperString . SaveEditing ( fileId , model . FileExtension , model . DownloadUri , stream , model . Doc , model . Forcesave ) ;
2020-03-18 13:19:37 +00:00
}
[Update("file/{fileId:int}/saveediting")]
2021-07-09 15:41:07 +00:00
public FileWrapper < int > SaveEditingFromForm ( int fileId , [ FromForm ] SaveEditingModel model )
2020-02-26 10:01:12 +00:00
{
2021-09-29 16:08:30 +00:00
using var stream = FilesControllerHelperInt . GetFileFromRequest ( model ) . OpenReadStream ( ) ;
2021-03-01 11:38:55 +00:00
return FilesControllerHelperInt . SaveEditing ( fileId , model . FileExtension , model . DownloadUri , stream , model . Doc , model . Forcesave ) ;
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-07-09 15:41:07 +00:00
public object StartEditFromBody ( string fileId , [ FromBody ] StartEditModel model )
2020-11-06 09:03:49 +00:00
{
return FilesControllerHelperString . StartEdit ( 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-07-09 15:41:07 +00:00
public object StartEditFromForm ( string fileId , [ FromForm ] StartEditModel model )
2020-02-26 10:01:12 +00:00
{
2020-10-31 15:14:37 +00:00
return FilesControllerHelperString . StartEdit ( 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-07-09 15:41:07 +00:00
public object StartEditFromBody ( int fileId , [ FromBody ] StartEditModel model )
2020-11-06 09:03:49 +00:00
{
return FilesControllerHelperInt . StartEdit ( fileId , model . EditingAlone , model . Doc ) ;
}
2021-10-06 19:43:28 +00:00
[Create("file/{fileId:int}/startedit")]
public object StartEdit ( int fileId )
{
return FilesControllerHelperInt . StartEdit ( fileId , false , null ) ;
}
2020-11-06 09:03:49 +00:00
[Create("file/{fileId:int}/startedit")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public object StartEditFromForm ( int fileId , [ FromForm ] StartEditModel model )
2020-03-18 13:19:37 +00:00
{
2020-10-31 15:14:37 +00:00
return FilesControllerHelperInt . StartEdit ( 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")]
2020-02-26 10:01:12 +00:00
public KeyValuePair < bool , string > TrackEditFile ( string fileId , Guid tabId , string docKeyForTrack , string doc , bool isFinish )
{
2020-03-18 13:19:37 +00:00
return FilesControllerHelperString . TrackEditFile ( fileId , tabId , docKeyForTrack , doc , isFinish ) ;
}
[Read("file/{fileId:int}/trackeditfile")]
public KeyValuePair < bool , string > TrackEditFile ( int fileId , Guid tabId , string docKeyForTrack , string doc , bool isFinish )
{
return FilesControllerHelperInt . TrackEditFile ( fileId , tabId , docKeyForTrack , doc , isFinish ) ;
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-09-15 10:26:56 +00:00
public Configuration < string > OpenEdit ( string fileId , int version , string doc , bool view )
2020-02-26 10:01:12 +00:00
{
2021-09-15 10:26:56 +00:00
return FilesControllerHelperString . OpenEdit ( 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-09-15 10:26:56 +00:00
public Configuration < int > OpenEdit ( int fileId , int version , string doc , bool view )
2020-03-18 13:19:37 +00:00
{
2021-09-15 10:26:56 +00:00
return FilesControllerHelperInt . OpenEdit ( 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-07-09 15:41:07 +00:00
public object CreateUploadSessionFromBody ( string folderId , [ FromBody ] SessionModel sessionModel )
2020-02-26 10:01:12 +00:00
{
2021-12-08 12:36:24 +00:00
return FilesControllerHelperString . CreateUploadSession ( folderId , sessionModel . FileName , sessionModel . FileSize , sessionModel . RelativePath , sessionModel . LastModified , sessionModel . Encrypted ) ;
2020-03-18 13:19:37 +00:00
}
2020-02-26 10:01:12 +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-07-09 15:41:07 +00:00
public object CreateUploadSessionFromForm ( string folderId , [ FromForm ] SessionModel sessionModel )
2020-02-26 10:01:12 +00:00
{
2021-12-08 12:36:24 +00:00
return FilesControllerHelperString . CreateUploadSession ( folderId , sessionModel . FileName , sessionModel . FileSize , sessionModel . RelativePath , sessionModel . LastModified , sessionModel . Encrypted ) ;
2020-03-18 13:19:37 +00:00
}
2020-02-26 10:01:12 +00:00
2020-03-18 13:19:37 +00:00
[Create("{folderId:int}/upload/create_session")]
2021-07-09 15:41:07 +00:00
public object CreateUploadSessionFromBody ( int folderId , [ FromBody ] SessionModel sessionModel )
2020-11-06 09:03:49 +00:00
{
2021-12-08 12:36:24 +00:00
return FilesControllerHelperInt . CreateUploadSession ( folderId , sessionModel . FileName , sessionModel . FileSize , sessionModel . RelativePath , sessionModel . LastModified , sessionModel . Encrypted ) ;
2020-11-06 09:03:49 +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-07-09 15:41:07 +00:00
public object CreateUploadSessionFromForm ( int folderId , [ FromForm ] SessionModel sessionModel )
2020-03-18 13:19:37 +00:00
{
2021-12-08 12:36:24 +00:00
return FilesControllerHelperInt . CreateUploadSession ( folderId , sessionModel . FileName , sessionModel . FileSize , sessionModel . RelativePath , sessionModel . LastModified , sessionModel . Encrypted ) ;
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-07-09 15:41:07 +00:00
public FileWrapper < int > CreateTextFileInMyFromBody ( [ FromBody ] CreateTextOrHtmlFileModel model )
2020-02-26 10:01:12 +00:00
{
2020-11-10 10:41:32 +00:00
return CreateTextFile ( GlobalFolderHelper . FolderMy , model ) ;
}
[Create("@my/text")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public FileWrapper < int > CreateTextFileInMyFromForm ( [ FromForm ] CreateTextOrHtmlFileModel model )
2020-02-26 10:01:12 +00:00
{
2020-11-10 10:41:32 +00:00
return CreateTextFile ( GlobalFolderHelper . FolderMy , model ) ;
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")]
2021-07-09 15:41:07 +00:00
public FileWrapper < int > CreateTextFileInCommonFromBody ( [ FromBody ] CreateTextOrHtmlFileModel model )
2020-02-26 10:01:12 +00:00
{
2020-11-10 10:41:32 +00:00
return CreateTextFile ( GlobalFolderHelper . FolderCommon , model ) ;
}
[Create("@common/text")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public FileWrapper < int > CreateTextFileInCommonFromForm ( [ FromForm ] CreateTextOrHtmlFileModel model )
2020-02-26 10:01:12 +00:00
{
2020-11-10 10:41:32 +00:00
return CreateTextFile ( GlobalFolderHelper . FolderCommon , model ) ;
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-07-09 15:41:07 +00:00
public FileWrapper < string > CreateTextFileFromBody ( string folderId , [ FromBody ] CreateTextOrHtmlFileModel model )
2020-02-26 10:01:12 +00:00
{
2020-11-10 10:41:32 +00:00
return CreateTextFile ( folderId , model ) ;
}
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-07-09 15:41:07 +00:00
public FileWrapper < string > CreateTextFileFromForm ( string folderId , [ FromForm ] CreateTextOrHtmlFileModel model )
2020-11-10 10:41:32 +00:00
{
return CreateTextFile ( folderId , model ) ;
}
private FileWrapper < string > CreateTextFile ( string folderId , CreateTextOrHtmlFileModel model )
2020-02-26 10:01:12 +00:00
{
2020-11-10 10:41:32 +00:00
return FilesControllerHelperString . CreateTextFile ( folderId , model . Title , model . Content ) ;
2020-02-26 10:01:12 +00:00
}
2020-03-18 13:19:37 +00:00
[Create("{folderId:int}/text")]
2021-07-09 15:41:07 +00:00
public FileWrapper < int > CreateTextFileFromBody ( int folderId , [ FromBody ] CreateTextOrHtmlFileModel model )
2020-02-26 10:01:12 +00:00
{
2020-11-10 10:41:32 +00:00
return CreateTextFile ( folderId , model ) ;
2020-02-26 10:01:12 +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-07-09 15:41:07 +00:00
public FileWrapper < int > CreateTextFileFromForm ( int folderId , [ FromForm ] CreateTextOrHtmlFileModel model )
2020-02-26 10:01:12 +00:00
{
2020-11-10 10:41:32 +00:00
return CreateTextFile ( folderId , model ) ;
}
private FileWrapper < int > CreateTextFile ( int folderId , CreateTextOrHtmlFileModel model )
{
return FilesControllerHelperInt . CreateTextFile ( folderId , model . Title , model . Content ) ;
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-07-09 15:41:07 +00:00
public FileWrapper < string > CreateHtmlFileFromBody ( string folderId , [ FromBody ] CreateTextOrHtmlFileModel model )
2020-02-26 10:01:12 +00:00
{
2020-11-10 10:41:32 +00:00
return CreateHtmlFile ( folderId , model ) ;
}
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-07-09 15:41:07 +00:00
public FileWrapper < string > CreateHtmlFileFromForm ( string folderId , [ FromForm ] CreateTextOrHtmlFileModel model )
2020-02-26 10:01:12 +00:00
{
2020-11-10 10:41:32 +00:00
return CreateHtmlFile ( folderId , model ) ;
}
private FileWrapper < string > CreateHtmlFile ( string folderId , CreateTextOrHtmlFileModel model )
{
return FilesControllerHelperString . CreateHtmlFile ( folderId , model . Title , model . Content ) ;
2020-03-18 13:19:37 +00:00
}
[Create("{folderId:int}/html")]
2021-07-09 15:41:07 +00:00
public FileWrapper < int > CreateHtmlFileFromBody ( int folderId , [ FromBody ] CreateTextOrHtmlFileModel model )
2020-03-18 13:19:37 +00:00
{
2020-11-10 10:41:32 +00:00
return CreateHtmlFile ( folderId , model ) ;
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")]
public FileWrapper < int > CreateHtmlFileFromForm ( int folderId , [ FromForm ] CreateTextOrHtmlFileModel model )
2020-03-18 13:19:37 +00:00
{
2020-11-10 10:41:32 +00:00
return CreateHtmlFile ( folderId , model ) ;
}
2021-07-09 15:41:07 +00:00
private FileWrapper < int > CreateHtmlFile ( int folderId , CreateTextOrHtmlFileModel model )
2020-11-10 10:41:32 +00:00
{
return FilesControllerHelperInt . CreateHtmlFile ( folderId , model . Title , model . Content ) ;
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>
[Create("@my/html")]
2021-07-09 15:41:07 +00:00
public FileWrapper < int > CreateHtmlFileInMyFromBody ( [ FromBody ] CreateTextOrHtmlFileModel model )
2020-02-26 10:01:12 +00:00
{
2020-11-10 10:41:32 +00:00
return CreateHtmlFile ( GlobalFolderHelper . FolderMy , model ) ;
2020-02-26 10:01:12 +00:00
}
2020-11-10 10:41:32 +00:00
[Create("@my/html")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public FileWrapper < int > CreateHtmlFileInMyFromForm ( [ FromForm ] CreateTextOrHtmlFileModel model )
2020-11-10 10:41:32 +00:00
{
return CreateHtmlFile ( GlobalFolderHelper . FolderMy , model ) ;
}
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")]
2021-07-09 15:41:07 +00:00
public FileWrapper < int > CreateHtmlFileInCommonFromBody ( [ FromBody ] CreateTextOrHtmlFileModel model )
2020-02-26 10:01:12 +00:00
{
2020-11-10 10:41:32 +00:00
return CreateHtmlFile ( GlobalFolderHelper . FolderCommon , model ) ;
2020-02-26 10:01:12 +00:00
}
2020-11-10 10:41:32 +00:00
[Create("@common/html")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public FileWrapper < int > CreateHtmlFileInCommonFromForm ( [ FromForm ] CreateTextOrHtmlFileModel model )
2020-11-10 10:41:32 +00:00
{
return CreateHtmlFile ( GlobalFolderHelper . FolderCommon , model ) ;
}
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-07-09 15:41:07 +00:00
public FolderWrapper < string > CreateFolderFromBody ( string folderId , [ FromBody ] CreateFolderModel folderModel )
2020-11-06 09:03:49 +00:00
{
return FilesControllerHelperString . CreateFolder ( folderId , folderModel . Title ) ;
}
2021-09-30 18:26:01 +00:00
[Create("folder/{folderId}", order: int.MaxValue, DisableFormat = true)]
2020-11-06 09:03:49 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public FolderWrapper < string > CreateFolderFromForm ( string folderId , [ FromForm ] CreateFolderModel folderModel )
2020-02-26 10:01:12 +00:00
{
2020-04-02 14:48:36 +00:00
return FilesControllerHelperString . CreateFolder ( folderId , folderModel . Title ) ;
2020-02-26 10:01:12 +00:00
}
2021-09-30 18:26:01 +00:00
[Create("folder/{folderId:int}", order: int.MaxValue - 1, DisableFormat = true)]
2021-07-09 15:41:07 +00:00
public FolderWrapper < int > CreateFolderFromBody ( int folderId , [ FromBody ] CreateFolderModel folderModel )
2020-03-18 13:19:37 +00:00
{
2020-04-02 14:48:36 +00:00
return FilesControllerHelperInt . CreateFolder ( folderId , folderModel . Title ) ;
2020-02-26 10:01:12 +00:00
}
2021-09-30 18:26:01 +00:00
[Create("folder/{folderId:int}", order: int.MaxValue - 1, DisableFormat = true)]
2020-11-06 09:03:49 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public FolderWrapper < int > CreateFolderFromForm ( int folderId , [ FromForm ] CreateFolderModel folderModel )
2020-11-06 09:03:49 +00:00
{
return FilesControllerHelperInt . CreateFolder ( folderId , folderModel . Title ) ;
}
2020-03-18 13:19:37 +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>
[Create("@my/file")]
2021-12-03 14:38:13 +00:00
public FileWrapper < int > CreateFileFromBody ( [ FromBody ] CreateFileModel < JsonElement > model )
2020-02-26 10:01:12 +00:00
{
2021-03-29 12:06:51 +00:00
return FilesControllerHelperInt . CreateFile ( GlobalFolderHelper . FolderMy , model . Title , model . TemplateId , model . EnableExternalExt ) ;
2020-11-06 09:03:49 +00:00
}
[Create("@my/file")]
[Consumes("application/x-www-form-urlencoded")]
2021-12-03 14:38:13 +00:00
public FileWrapper < int > CreateFileFromForm ( [ FromForm ] CreateFileModel < JsonElement > model )
2020-11-06 09:03:49 +00:00
{
2021-03-29 12:06:51 +00:00
return FilesControllerHelperInt . CreateFile ( GlobalFolderHelper . FolderMy , model . Title , model . TemplateId , model . EnableExternalExt ) ;
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-05-05 11:48:15 +00:00
[Create("{folderId}/file")]
2021-12-03 14:38:13 +00:00
public FileWrapper < string > CreateFileFromBody ( string folderId , [ FromBody ] CreateFileModel < JsonElement > model )
2020-02-26 10:01:12 +00:00
{
2021-03-29 12:06:51 +00:00
return FilesControllerHelperString . CreateFile ( folderId , model . Title , model . TemplateId , model . EnableExternalExt ) ;
2020-03-18 13:19:37 +00:00
}
2021-05-05 11:48:15 +00:00
[Create("{folderId}/file")]
2020-11-06 09:03:49 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-12-03 14:38:13 +00:00
public FileWrapper < string > CreateFileFromForm ( string folderId , [ FromForm ] CreateFileModel < JsonElement > model )
2020-02-26 10:01:12 +00:00
{
2021-03-29 12:06:51 +00:00
return FilesControllerHelperString . CreateFile ( folderId , model . Title , model . TemplateId , model . EnableExternalExt ) ;
2020-03-18 13:19:37 +00:00
}
[Create("{folderId:int}/file")]
2021-12-03 14:38:13 +00:00
public FileWrapper < int > CreateFileFromBody ( int folderId , [ FromBody ] CreateFileModel < JsonElement > model )
2020-11-06 09:03:49 +00:00
{
2021-03-29 12:06:51 +00:00
return FilesControllerHelperInt . CreateFile ( folderId , model . Title , model . TemplateId , model . EnableExternalExt ) ;
2020-11-06 09:03:49 +00:00
}
2020-03-18 13:19:37 +00:00
[Create("{folderId:int}/file")]
2020-11-06 09:03:49 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-12-03 14:38:13 +00:00
public FileWrapper < int > CreateFileFromForm ( int folderId , [ FromForm ] CreateFileModel < JsonElement > model )
2020-02-26 10:01:12 +00:00
{
2021-03-29 12:06:51 +00:00
return FilesControllerHelperInt . CreateFile ( folderId , model . Title , model . TemplateId , model . EnableExternalExt ) ;
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>
2021-09-30 18:26:01 +00:00
[Update("folder/{folderId}", order: int.MaxValue, DisableFormat = true)]
2021-07-09 15:41:07 +00:00
public FolderWrapper < string > RenameFolderFromBody ( string folderId , [ FromBody ] CreateFolderModel folderModel )
2020-11-06 09:03:49 +00:00
{
return FilesControllerHelperString . RenameFolder ( folderId , folderModel . Title ) ;
}
2021-09-30 18:26:01 +00:00
[Update("folder/{folderId}", order: int.MaxValue, DisableFormat = true)]
2020-11-06 09:03:49 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public FolderWrapper < string > RenameFolderFromForm ( string folderId , [ FromForm ] CreateFolderModel folderModel )
2020-02-26 10:01:12 +00:00
{
2020-04-02 14:48:36 +00:00
return FilesControllerHelperString . RenameFolder ( folderId , folderModel . Title ) ;
2020-03-18 13:19:37 +00:00
}
2021-09-30 18:26:01 +00:00
[Update("folder/{folderId:int}", order: int.MaxValue - 1, DisableFormat = true)]
2021-07-09 15:41:07 +00:00
public FolderWrapper < int > RenameFolderFromBody ( int folderId , [ FromBody ] CreateFolderModel folderModel )
2020-11-06 09:03:49 +00:00
{
return FilesControllerHelperInt . RenameFolder ( folderId , folderModel . Title ) ;
}
2021-09-30 18:26:01 +00:00
[Update("folder/{folderId:int}", order: int.MaxValue - 1, DisableFormat = true)]
2020-11-06 09:03:49 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public FolderWrapper < int > RenameFolderFromForm ( int folderId , [ FromForm ] CreateFolderModel folderModel )
2020-03-18 13:19:37 +00:00
{
2020-04-02 14:48:36 +00:00
return FilesControllerHelperInt . RenameFolder ( folderId , folderModel . Title ) ;
2020-02-26 10:01:12 +00:00
}
2020-12-01 19:59:42 +00:00
[Create("owner")]
public IEnumerable < FileEntryWrapper > ChangeOwnerFromBody ( [ FromBody ] ChangeOwnerModel model )
{
return ChangeOwner ( model ) ;
}
[Create("owner")]
[Consumes("application/x-www-form-urlencoded")]
public IEnumerable < FileEntryWrapper > ChangeOwnerFromForm ( [ FromForm ] ChangeOwnerModel model )
{
return ChangeOwner ( model ) ;
}
public IEnumerable < FileEntryWrapper > ChangeOwner ( ChangeOwnerModel model )
{
2021-09-28 15:12:06 +00:00
var ( folderIntIds , folderStringIds ) = FileOperationsManager . GetIds ( model . FolderIds ) ;
var ( fileIntIds , fileStringIds ) = FileOperationsManager . GetIds ( model . FileIds ) ;
2020-12-01 19:59:42 +00:00
var result = new List < FileEntry > ( ) ;
2021-09-28 15:12:06 +00:00
result . AddRange ( FileStorageServiceInt . ChangeOwner ( folderIntIds , fileIntIds , model . UserId ) ) ;
result . AddRange ( FileStorageService . ChangeOwner ( folderStringIds , fileStringIds , model . UserId ) ) ;
2021-04-13 09:46:25 +00:00
return result . Select ( FilesControllerHelperInt . GetFileEntryWrapper ) . ToList ( ) ;
2020-12-01 19:59:42 +00:00
}
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-09-30 18:26:01 +00:00
[Read("folder/{folderId}", order: int.MaxValue, DisableFormat = true)]
2020-03-05 07:24:50 +00:00
public FolderWrapper < string > GetFolderInfo ( string folderId )
2020-02-26 10:01:12 +00:00
{
2020-03-18 13:19:37 +00:00
return FilesControllerHelperString . GetFolderInfo ( folderId ) ;
}
2020-02-26 10:01:12 +00:00
2021-09-30 18:26:01 +00:00
[Read("folder/{folderId:int}", order: int.MaxValue - 1, DisableFormat = true)]
2020-03-18 13:19:37 +00:00
public FolderWrapper < int > GetFolderInfo ( int folderId )
{
return FilesControllerHelperInt . GetFolderInfo ( folderId ) ;
2020-02-26 10:01:12 +00:00
}
/// <summary>
/// Returns parent folders
/// </summary>
/// <param name="folderId"></param>
/// <category>Folders</category>
/// <returns>Parent folders</returns>
2021-05-05 11:48:15 +00:00
[Read("folder/{folderId}/path")]
2020-11-06 12:10:27 +00:00
public IEnumerable < FileEntryWrapper > GetFolderPath ( string folderId )
2020-02-26 10:01:12 +00:00
{
2020-03-18 13:19:37 +00:00
return FilesControllerHelperString . GetFolderPath ( folderId ) ;
}
[Read("folder/{folderId:int}/path")]
2020-11-06 12:10:27 +00:00
public IEnumerable < FileEntryWrapper > GetFolderPath ( int folderId )
2020-02-26 10:01:12 +00:00
{
2020-03-18 13:19:37 +00:00
return FilesControllerHelperInt . GetFolderPath ( folderId ) ;
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>
2021-09-29 10:17:32 +00:00
[Read("file/{fileId}", order: int.MaxValue, DisableFormat = true)]
2020-03-05 07:24:50 +00:00
public FileWrapper < string > GetFileInfo ( string fileId , int version = - 1 )
2020-02-26 10:01:12 +00:00
{
2020-03-18 13:19:37 +00:00
return FilesControllerHelperString . GetFileInfo ( fileId , version ) ;
2020-02-28 11:32:11 +00:00
}
2021-09-30 18:26:01 +00:00
[Read("file/{fileId:int}", order: int.MaxValue - 1, DisableFormat = true)]
2020-03-05 07:24:50 +00:00
public FileWrapper < int > GetFileInfo ( int fileId , int version = - 1 )
2020-02-26 10:01:12 +00:00
{
2020-03-18 13:19:37 +00:00
return FilesControllerHelperInt . GetFileInfo ( fileId , version ) ;
2020-02-26 10:01:12 +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 )
{
return helper . CopyFileAs ( fileId , model . DestFolderId . GetInt32 ( ) , model . DestTitle , model . Password ) ;
}
else if ( model . DestFolderId . ValueKind = = JsonValueKind . String )
{
return helper . CopyFileAs ( fileId , model . DestFolderId . GetString ( ) , model . DestTitle , model . Password ) ;
}
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>
2021-09-30 18:26:01 +00:00
[Update("file/{fileId}", order: int.MaxValue, DisableFormat = true)]
2021-07-09 15:41:07 +00:00
public FileWrapper < string > UpdateFileFromBody ( string fileId , [ FromBody ] UpdateFileModel model )
2020-02-26 10:01:12 +00:00
{
2020-08-02 18:48:58 +00:00
return FilesControllerHelperString . UpdateFile ( fileId , model . Title , model . LastVersion ) ;
2020-03-18 13:19:37 +00:00
}
2020-02-26 10:01:12 +00:00
2021-09-30 18:26:01 +00:00
[Update("file/{fileId}", order: int.MaxValue, DisableFormat = true)]
2020-11-06 09:03:49 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public FileWrapper < string > UpdateFileFromForm ( string fileId , [ FromForm ] UpdateFileModel model )
2020-02-26 10:01:12 +00:00
{
2020-08-02 18:48:58 +00:00
return FilesControllerHelperString . UpdateFile ( fileId , model . Title , model . LastVersion ) ;
2020-03-18 13:19:37 +00:00
}
2020-02-26 10:01:12 +00:00
2021-09-30 18:26:01 +00:00
[Update("file/{fileId:int}", order: int.MaxValue - 1, DisableFormat = true)]
2021-07-09 15:41:07 +00:00
public FileWrapper < int > UpdateFileFromBody ( int fileId , [ FromBody ] UpdateFileModel model )
2020-11-06 09:03:49 +00:00
{
return FilesControllerHelperInt . UpdateFile ( fileId , model . Title , model . LastVersion ) ;
}
2021-09-30 18:26:01 +00:00
[Update("file/{fileId:int}", order: int.MaxValue - 1, DisableFormat = true)]
2020-11-06 09:03:49 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public FileWrapper < int > UpdateFileFromForm ( int fileId , [ FromForm ] UpdateFileModel model )
2020-03-18 13:19:37 +00:00
{
2020-08-02 18:48:58 +00:00
return FilesControllerHelperInt . UpdateFile ( fileId , model . Title , model . LastVersion ) ;
2020-02-26 10:01:12 +00:00
}
2021-09-30 18:26:01 +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)]
2021-01-29 07:17:56 +00:00
public IEnumerable < FileOperationWraper > DeleteFile ( string fileId , [ FromBody ] DeleteModel model )
2020-02-26 10:01:12 +00:00
{
2021-01-29 07:17:56 +00:00
return FilesControllerHelperString . DeleteFile ( 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)]
2021-01-29 07:17:56 +00:00
public IEnumerable < FileOperationWraper > DeleteFile ( int fileId , [ FromBody ] DeleteModel model )
2020-03-18 13:19:37 +00:00
{
2021-01-29 07:17:56 +00:00
return FilesControllerHelperInt . DeleteFile ( 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>
2021-05-05 11:48:15 +00:00
[Update("file/{fileId}/checkconversion")]
2021-12-08 17:17:50 +00:00
public IEnumerable < ConversationResult < string > > StartConversion ( string fileId , [ FromBody ( EmptyBodyBehavior = Microsoft . AspNetCore . Mvc . ModelBinding . EmptyBodyBehavior . Allow ) ] CheckConversionModel < string > model )
2020-02-26 10:01:12 +00:00
{
2022-02-01 18:12:56 +00:00
if ( model = = null )
{
model = new CheckConversionModel < string > ( ) ;
}
2021-12-08 17:17:50 +00:00
model . FileId = fileId ;
return FilesControllerHelperString . StartConversion ( model ) ;
2020-03-18 13:19:37 +00:00
}
[Update("file/{fileId:int}/checkconversion")]
2021-12-08 17:17:50 +00:00
public IEnumerable < ConversationResult < int > > StartConversion ( int fileId , [ FromBody ( EmptyBodyBehavior = Microsoft . AspNetCore . Mvc . ModelBinding . EmptyBodyBehavior . Allow ) ] CheckConversionModel < int > model )
2020-03-18 13:19:37 +00:00
{
2022-02-01 18:12:56 +00:00
if ( model = = null )
{
model = new CheckConversionModel < int > ( ) ;
}
2021-12-08 17:17:50 +00:00
model . FileId = fileId ;
return FilesControllerHelperInt . StartConversion ( model ) ;
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>
2021-05-05 11:48:15 +00:00
[Read("file/{fileId}/checkconversion")]
2020-03-18 13:19:37 +00:00
public IEnumerable < ConversationResult < string > > CheckConversion ( string fileId , bool start )
2020-02-26 10:01:12 +00:00
{
2021-12-08 17:17:50 +00:00
return FilesControllerHelperString . CheckConversion ( new CheckConversionModel < string > ( )
{
FileId = fileId ,
StartConvert = start
} ) ;
2020-03-18 13:19:37 +00:00
}
[Read("file/{fileId:int}/checkconversion")]
public IEnumerable < ConversationResult < int > > CheckConversion ( int fileId , bool start )
{
2021-12-08 17:17:50 +00:00
return FilesControllerHelperInt . CheckConversion ( new CheckConversionModel < int > ( )
{
FileId = fileId ,
StartConvert = start
} ) ;
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)]
2020-02-26 10:01:12 +00:00
public IEnumerable < FileOperationWraper > DeleteFolder ( string folderId , bool deleteAfter , bool immediately )
{
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}")]
2020-03-24 12:30:16 +00:00
public 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-09-28 08:57:03 +00:00
[Read("fileops/move")]
2021-09-30 09:21:48 +00:00
public IEnumerable < FileEntryWrapper > MoveOrCopyBatchCheck ( [ ModelBinder ( BinderType = typeof ( BatchModelBinder ) ) ] BatchModel batchModel )
2020-11-06 09:03:49 +00:00
{
2021-09-30 09:21:48 +00:00
return FilesControllerHelperString . MoveOrCopyBatchCheck ( batchModel ) ;
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")]
2021-07-09 15:41:07 +00:00
public IEnumerable < FileOperationWraper > MoveBatchItemsFromBody ( [ FromBody ] BatchModel batchModel )
2020-11-06 09:03:49 +00:00
{
return FilesControllerHelperString . MoveBatchItems ( batchModel ) ;
}
[Update("fileops/move")]
[Consumes("application/x-www-form-urlencoded")]
2021-09-30 09:21:48 +00:00
public IEnumerable < FileOperationWraper > MoveBatchItemsFromForm ( [ FromForm ] [ ModelBinder ( BinderType = typeof ( BatchModelBinder ) ) ] BatchModel batchModel )
2020-02-26 10:01:12 +00:00
{
2020-03-18 13:19:37 +00:00
return FilesControllerHelperString . MoveBatchItems ( 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")]
2021-07-09 15:41:07 +00:00
public IEnumerable < FileOperationWraper > CopyBatchItemsFromBody ( [ FromBody ] BatchModel batchModel )
2020-11-06 09:03:49 +00:00
{
return FilesControllerHelperString . CopyBatchItems ( batchModel ) ;
}
[Update("fileops/copy")]
[Consumes("application/x-www-form-urlencoded")]
2021-09-30 09:21:48 +00:00
public IEnumerable < FileOperationWraper > CopyBatchItemsFromForm ( [ FromForm ] [ ModelBinder ( BinderType = typeof ( BatchModelBinder ) ) ] BatchModel batchModel )
2020-02-26 10:01:12 +00:00
{
2020-03-18 13:19:37 +00:00
return FilesControllerHelperString . CopyBatchItems ( 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")]
2021-09-30 06:52:46 +00:00
public IEnumerable < FileOperationWraper > MarkAsReadFromBody ( [ FromBody ] BaseBatchModel model )
2020-11-06 09:03:49 +00:00
{
return FilesControllerHelperString . MarkAsRead ( model ) ;
}
[Update("fileops/markasread")]
[Consumes("application/x-www-form-urlencoded")]
2021-09-30 18:26:01 +00:00
public IEnumerable < FileOperationWraper > MarkAsReadFromForm ( [ FromForm ] [ ModelBinder ( BinderType = typeof ( BaseBatchModelBinder ) ) ] BaseBatchModel model )
2020-02-26 10:01:12 +00:00
{
2020-03-18 13:19:37 +00:00
return FilesControllerHelperString . MarkAsRead ( 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>
[Update("fileops/terminate")]
public IEnumerable < FileOperationWraper > TerminateTasks ( )
{
return FileStorageService . TerminateTasks ( ) . Select ( FileOperationWraperHelper . Get ) ;
}
/// <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")]
public IEnumerable < FileOperationWraper > GetOperationStatuses ( )
{
return FileStorageService . GetTasksStatuses ( ) . Select ( FileOperationWraperHelper . Get ) ;
}
/// <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")]
2021-07-09 15:41:07 +00:00
public IEnumerable < FileOperationWraper > BulkDownload ( [ FromBody ] DownloadModel model )
2020-11-06 09:03:49 +00:00
{
return FilesControllerHelperString . BulkDownload ( model ) ;
}
[Update("fileops/bulkdownload")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public IEnumerable < FileOperationWraper > BulkDownloadFromForm ( [ FromForm ] DownloadModel model )
2020-02-26 10:01:12 +00:00
{
2020-03-18 13:19:37 +00:00
return FilesControllerHelperString . BulkDownload ( 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")]
2021-07-09 15:41:07 +00:00
public IEnumerable < FileOperationWraper > DeleteBatchItemsFromBody ( [ FromBody ] DeleteBatchModel batch )
2020-11-06 09:03:49 +00:00
{
return FileStorageService . DeleteItems ( "delete" , batch . FileIds . ToList ( ) , batch . FolderIds . ToList ( ) , false , batch . DeleteAfter , batch . Immediately )
. Select ( FileOperationWraperHelper . Get ) ;
}
[Update("fileops/delete")]
[Consumes("application/x-www-form-urlencoded")]
2021-09-30 06:52:46 +00:00
public IEnumerable < FileOperationWraper > DeleteBatchItemsFromForm ( [ FromForm ] [ ModelBinder ( BinderType = typeof ( DeleteBatchModelBinder ) ) ] DeleteBatchModel batch )
2020-02-26 10:01:12 +00:00
{
2020-03-19 12:56:34 +00:00
return FileStorageService . DeleteItems ( "delete" , batch . FileIds . ToList ( ) , batch . FolderIds . ToList ( ) , false , batch . DeleteAfter , batch . Immediately )
2020-03-24 12:30:16 +00:00
. Select ( FileOperationWraperHelper . Get ) ;
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")]
public IEnumerable < FileOperationWraper > EmptyTrash ( )
{
2020-03-19 12:56:34 +00:00
return FilesControllerHelperInt . EmptyTrash ( ) ;
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-05-05 11:48:15 +00:00
[Read("file/{fileId}/history")]
2020-03-05 07:24:50 +00:00
public IEnumerable < FileWrapper < string > > GetFileVersionInfo ( string fileId )
2020-02-26 10:01:12 +00:00
{
2020-03-18 13:19:37 +00:00
return FilesControllerHelperString . GetFileVersionInfo ( fileId ) ;
}
[Read("file/{fileId:int}/history")]
public IEnumerable < FileWrapper < int > > GetFileVersionInfo ( int fileId )
{
return FilesControllerHelperInt . GetFileVersionInfo ( fileId ) ;
2020-02-26 10:01:12 +00:00
}
2021-08-11 15:04:23 +00:00
[Read("file/{fileId}/presigned")]
public DocumentService . FileLink GetPresignedUri ( string fileId )
{
return FilesControllerHelperString . GetPresignedUri ( fileId ) ;
}
[Read("file/{fileId:int}/presigned")]
public DocumentService . FileLink GetPresignedUri ( int fileId )
{
return FilesControllerHelperInt . GetPresignedUri ( fileId ) ;
}
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>
/// <returns></returns>
2021-05-05 11:48:15 +00:00
[Update("file/{fileId}/history")]
2021-07-09 15:41:07 +00:00
public IEnumerable < FileWrapper < string > > ChangeHistoryFromBody ( string fileId , [ FromBody ] ChangeHistoryModel model )
2020-11-06 09:03:49 +00:00
{
return FilesControllerHelperString . ChangeHistory ( fileId , model . Version , model . ContinueVersion ) ;
}
2021-05-05 11:48:15 +00:00
[Update("file/{fileId}/history")]
2020-11-06 09:03:49 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public IEnumerable < FileWrapper < string > > ChangeHistoryFromForm ( string fileId , [ FromForm ] ChangeHistoryModel model )
2020-02-26 10:01:12 +00:00
{
2020-08-02 18:48:58 +00:00
return FilesControllerHelperString . ChangeHistory ( fileId , model . Version , model . ContinueVersion ) ;
2020-03-18 13:19:37 +00:00
}
2020-08-02 18:48:58 +00:00
2020-03-18 13:19:37 +00:00
[Update("file/{fileId:int}/history")]
2021-07-09 15:41:07 +00:00
public IEnumerable < FileWrapper < int > > ChangeHistoryFromBody ( int fileId , [ FromBody ] ChangeHistoryModel model )
2020-08-02 18:48:58 +00:00
{
return FilesControllerHelperInt . ChangeHistory ( fileId , model . Version , model . ContinueVersion ) ;
}
2020-11-06 09:03:49 +00:00
[Update("file/{fileId:int}/history")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public IEnumerable < FileWrapper < int > > ChangeHistoryFromForm ( int fileId , [ FromForm ] ChangeHistoryModel model )
2020-11-06 09:03:49 +00:00
{
return FilesControllerHelperInt . ChangeHistory ( fileId , model . Version , model . ContinueVersion ) ;
}
2021-05-05 11:48:15 +00:00
[Update("file/{fileId}/lock")]
2021-07-09 15:41:07 +00:00
public FileWrapper < string > LockFileFromBody ( string fileId , [ FromBody ] LockFileModel model )
2020-11-06 09:03:49 +00:00
{
return FilesControllerHelperString . LockFile ( fileId , model . LockFile ) ;
}
2021-05-05 11:48:15 +00:00
[Update("file/{fileId}/lock")]
2020-11-06 09:03:49 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public FileWrapper < string > LockFileFromForm ( string fileId , [ FromForm ] LockFileModel model )
2020-08-12 15:13:52 +00:00
{
return FilesControllerHelperString . LockFile ( fileId , model . LockFile ) ;
}
[Update("file/{fileId:int}/lock")]
2021-07-09 15:41:07 +00:00
public FileWrapper < int > LockFileFromBody ( int fileId , [ FromBody ] LockFileModel model )
2020-11-06 09:03:49 +00:00
{
return FilesControllerHelperInt . LockFile ( fileId , model . LockFile ) ;
}
[Update("file/{fileId:int}/lock")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public FileWrapper < int > LockFileFromForm ( int fileId , [ FromForm ] LockFileModel model )
2020-08-12 15:13:52 +00:00
{
return FilesControllerHelperInt . LockFile ( fileId , model . LockFile ) ;
}
2021-12-08 12:25:39 +00:00
[AllowAnonymous]
[Read("file/{fileId}/edit/history")]
public List < EditHistoryWrapper > GetEditHistory ( string fileId , string doc = null )
{
return FilesControllerHelperString . GetEditHistory ( fileId , doc ) ;
}
[AllowAnonymous]
[Read("file/{fileId:int}/edit/history")]
public List < EditHistoryWrapper > GetEditHistory ( int fileId , string doc = null )
{
return FilesControllerHelperInt . GetEditHistory ( fileId , doc ) ;
}
[AllowAnonymous]
[Read("file/{fileId}/edit/diff")]
public EditHistoryData GetEditDiffUrl ( string fileId , int version = 0 , string doc = null )
{
return FilesControllerHelperString . GetEditDiffUrl ( fileId , version , doc ) ;
}
[AllowAnonymous]
[Read("file/{fileId:int}/edit/diff")]
public EditHistoryData GetEditDiffUrl ( int fileId , int version = 0 , string doc = null )
{
return FilesControllerHelperInt . GetEditDiffUrl ( fileId , version , doc ) ;
}
[AllowAnonymous]
[Read("file/{fileId}/restoreversion")]
public List < EditHistoryWrapper > RestoreVersion ( string fileId , int version = 0 , string url = null , string doc = null )
{
return FilesControllerHelperString . RestoreVersion ( fileId , version , url , doc ) ;
}
[AllowAnonymous]
[Read("file/{fileId:int}/restoreversion")]
public List < EditHistoryWrapper > RestoreVersion ( int fileId , int version = 0 , string url = null , string doc = null )
{
return FilesControllerHelperInt . RestoreVersion ( fileId , version , url , doc ) ;
}
2021-05-05 11:48:15 +00:00
[Update("file/{fileId}/comment")]
2021-07-09 15:41:07 +00:00
public object UpdateCommentFromBody ( string fileId , [ FromBody ] UpdateCommentModel model )
2020-08-02 18:48:58 +00:00
{
return FilesControllerHelperString . UpdateComment ( fileId , model . Version , model . Comment ) ;
}
2021-05-05 11:48:15 +00:00
[Update("file/{fileId}/comment")]
2020-11-06 09:03:49 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public object UpdateCommentFromForm ( string fileId , [ FromForm ] UpdateCommentModel model )
2020-08-02 18:48:58 +00:00
{
return FilesControllerHelperString . UpdateComment ( fileId , model . Version , model . Comment ) ;
}
[Update("file/{fileId:int}/comment")]
2021-07-09 15:41:07 +00:00
public object UpdateCommentFromBody ( int fileId , [ FromBody ] UpdateCommentModel model )
2020-11-06 09:03:49 +00:00
{
return FilesControllerHelperInt . UpdateComment ( fileId , model . Version , model . Comment ) ;
}
2020-08-02 18:48:58 +00:00
[Update("file/{fileId:int}/comment")]
2020-11-06 09:03:49 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public object UpdateCommentFromForm ( int fileId , [ FromForm ] UpdateCommentModel model )
2020-02-26 10:01:12 +00:00
{
2020-08-02 18:48:58 +00:00
return FilesControllerHelperInt . UpdateComment ( 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>
2021-05-05 11:48:15 +00:00
[Read("file/{fileId}/share")]
2020-02-26 10:01:12 +00:00
public IEnumerable < FileShareWrapper > GetFileSecurityInfo ( string fileId )
{
2020-03-18 13:19:37 +00:00
return FilesControllerHelperString . GetFileSecurityInfo ( fileId ) ;
}
[Read("file/{fileId:int}/share")]
public IEnumerable < FileShareWrapper > GetFileSecurityInfo ( int fileId )
{
return FilesControllerHelperInt . GetFileSecurityInfo ( fileId ) ;
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>
2021-05-05 11:48:15 +00:00
[Read("folder/{folderId}/share")]
2020-02-26 10:01:12 +00:00
public IEnumerable < FileShareWrapper > GetFolderSecurityInfo ( string folderId )
{
2020-03-18 13:19:37 +00:00
return FilesControllerHelperString . GetFolderSecurityInfo ( folderId ) ;
}
[Read("folder/{folderId:int}/share")]
public IEnumerable < FileShareWrapper > GetFolderSecurityInfo ( int folderId )
{
return FilesControllerHelperInt . GetFolderSecurityInfo ( folderId ) ;
2020-02-26 10:01:12 +00:00
}
2020-12-03 14:50:17 +00:00
[Create("share")]
2021-09-30 06:52:46 +00:00
public IEnumerable < FileShareWrapper > GetSecurityInfoFromBody ( [ FromBody ] BaseBatchModel model )
2020-12-02 13:17:43 +00:00
{
2021-09-28 15:12:06 +00:00
var ( folderIntIds , folderStringIds ) = FileOperationsManager . GetIds ( model . FolderIds ) ;
var ( fileIntIds , fileStringIds ) = FileOperationsManager . GetIds ( model . FileIds ) ;
2020-12-02 13:17:43 +00:00
var result = new List < FileShareWrapper > ( ) ;
2021-09-28 15:12:06 +00:00
result . AddRange ( FilesControllerHelperInt . GetSecurityInfo ( fileIntIds , folderIntIds ) ) ;
result . AddRange ( FilesControllerHelperString . GetSecurityInfo ( fileStringIds , folderStringIds ) ) ;
2020-12-02 13:17:43 +00:00
return result ;
}
2020-12-03 14:50:17 +00:00
[Create("share")]
2020-12-02 13:17:43 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-09-30 18:26:01 +00:00
public IEnumerable < FileShareWrapper > GetSecurityInfoFromForm ( [ FromForm ] [ ModelBinder ( BinderType = typeof ( BaseBatchModelBinder ) ) ] BaseBatchModel model )
2020-12-02 13:17:43 +00:00
{
2021-09-28 15:12:06 +00:00
var ( folderIntIds , folderStringIds ) = FileOperationsManager . GetIds ( model . FolderIds ) ;
var ( fileIntIds , fileStringIds ) = FileOperationsManager . GetIds ( model . FileIds ) ;
2020-12-02 13:17:43 +00:00
var result = new List < FileShareWrapper > ( ) ;
2021-09-28 15:12:06 +00:00
result . AddRange ( FilesControllerHelperInt . GetSecurityInfo ( fileIntIds , folderIntIds ) ) ;
result . AddRange ( FilesControllerHelperString . GetSecurityInfo ( fileStringIds , folderStringIds ) ) ;
2020-12-02 13:17:43 +00:00
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>
2021-05-05 11:48:15 +00:00
[Update("file/{fileId}/share")]
2021-07-09 15:41:07 +00:00
public IEnumerable < FileShareWrapper > SetFileSecurityInfoFromBody ( string fileId , [ FromBody ] SecurityInfoModel model )
2020-11-06 09:03:49 +00:00
{
return FilesControllerHelperString . SetFileSecurityInfo ( fileId , model . Share , model . Notify , model . SharingMessage ) ;
}
2021-05-05 11:48:15 +00:00
[Update("file/{fileId}/share")]
2020-11-06 09:03:49 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public IEnumerable < FileShareWrapper > SetFileSecurityInfoFromForm ( string fileId , [ FromForm ] SecurityInfoModel model )
2020-02-26 10:01:12 +00:00
{
2020-05-06 15:10:27 +00:00
return FilesControllerHelperString . SetFileSecurityInfo ( fileId , model . Share , model . Notify , model . SharingMessage ) ;
2020-03-18 13:19:37 +00:00
}
[Update("file/{fileId:int}/share")]
2021-07-09 15:41:07 +00:00
public IEnumerable < FileShareWrapper > SetFileSecurityInfoFromBody ( int fileId , [ FromBody ] SecurityInfoModel model )
2020-11-06 09:03:49 +00:00
{
return FilesControllerHelperInt . SetFileSecurityInfo ( fileId , model . Share , model . Notify , model . SharingMessage ) ;
}
[Update("file/{fileId:int}/share")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public IEnumerable < FileShareWrapper > SetFileSecurityInfoFromForm ( int fileId , [ FromForm ] SecurityInfoModel model )
2020-03-18 13:19:37 +00:00
{
2020-05-06 15:10:27 +00:00
return FilesControllerHelperInt . SetFileSecurityInfo ( fileId , model . Share , model . Notify , model . SharingMessage ) ;
2020-02-26 10:01:12 +00:00
}
2020-12-03 14:43:33 +00:00
[Update("share")]
2021-07-09 15:41:07 +00:00
public IEnumerable < FileShareWrapper > SetSecurityInfoFromBody ( [ FromBody ] SecurityInfoModel model )
2020-12-03 14:43:33 +00:00
{
return SetSecurityInfo ( model ) ;
}
[Update("share")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public IEnumerable < FileShareWrapper > SetSecurityInfoFromForm ( [ FromForm ] SecurityInfoModel model )
2020-12-03 14:43:33 +00:00
{
return SetSecurityInfo ( model ) ;
2021-07-09 15:41:07 +00:00
}
2020-12-03 14:43:33 +00:00
public IEnumerable < FileShareWrapper > SetSecurityInfo ( SecurityInfoModel model )
{
2021-09-28 15:12:06 +00:00
var ( folderIntIds , folderStringIds ) = FileOperationsManager . GetIds ( model . FolderIds ) ;
var ( fileIntIds , fileStringIds ) = FileOperationsManager . GetIds ( model . FileIds ) ;
2020-12-03 14:43:33 +00:00
var result = new List < FileShareWrapper > ( ) ;
2021-09-28 15:12:06 +00:00
result . AddRange ( FilesControllerHelperInt . SetSecurityInfo ( fileIntIds , folderIntIds , model . Share , model . Notify , model . SharingMessage ) ) ;
result . AddRange ( FilesControllerHelperString . SetSecurityInfo ( fileStringIds , folderStringIds , model . Share , model . Notify , model . SharingMessage ) ) ;
2020-12-03 14:43:33 +00:00
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>
2021-05-05 11:48:15 +00:00
[Update("folder/{folderId}/share")]
2021-07-09 15:41:07 +00:00
public IEnumerable < FileShareWrapper > SetFolderSecurityInfoFromBody ( string folderId , [ FromBody ] SecurityInfoModel model )
2020-02-26 10:01:12 +00:00
{
2020-05-06 15:10:27 +00:00
return FilesControllerHelperString . SetFolderSecurityInfo ( folderId , model . Share , model . Notify , model . SharingMessage ) ;
2020-03-18 13:19:37 +00:00
}
2020-11-06 09:03:49 +00:00
2021-05-05 11:48:15 +00:00
[Update("folder/{folderId}/share")]
2020-11-06 09:03:49 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public IEnumerable < FileShareWrapper > SetFolderSecurityInfoFromForm ( string folderId , [ FromForm ] SecurityInfoModel model )
2020-11-06 09:03:49 +00:00
{
return FilesControllerHelperString . SetFolderSecurityInfo ( folderId , model . Share , model . Notify , model . SharingMessage ) ;
}
2020-03-18 13:19:37 +00:00
[Update("folder/{folderId:int}/share")]
2021-07-09 15:41:07 +00:00
public IEnumerable < FileShareWrapper > SetFolderSecurityInfoFromBody ( int folderId , [ FromBody ] SecurityInfoModel model )
2020-11-06 09:03:49 +00:00
{
return FilesControllerHelperInt . SetFolderSecurityInfo ( folderId , model . Share , model . Notify , model . SharingMessage ) ;
}
[Update("folder/{folderId:int}/share")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public IEnumerable < FileShareWrapper > SetFolderSecurityInfoFromForm ( int folderId , [ FromForm ] SecurityInfoModel model )
2020-03-18 13:19:37 +00:00
{
2020-05-06 15:10:27 +00:00
return FilesControllerHelperInt . SetFolderSecurityInfo ( folderId , model . Share , model . Notify , model . SharingMessage ) ;
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>
[Delete("share")]
2021-09-30 06:52:46 +00:00
public bool RemoveSecurityInfo ( BaseBatchModel model )
2020-02-26 10:01:12 +00:00
{
2021-09-28 15:12:06 +00:00
var ( folderIntIds , folderStringIds ) = FileOperationsManager . GetIds ( model . FolderIds ) ;
var ( fileIntIds , fileStringIds ) = FileOperationsManager . GetIds ( model . FileIds ) ;
FilesControllerHelperInt . RemoveSecurityInfo ( fileIntIds , folderIntIds ) ;
FilesControllerHelperString . RemoveSecurityInfo ( fileStringIds , folderStringIds ) ;
2020-02-26 10:01:12 +00:00
return true ;
}
/// <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>
2021-05-05 11:48:15 +00:00
[Update("{fileId}/sharedlink")]
2021-07-09 15:41:07 +00:00
public object GenerateSharedLinkFromBody ( string fileId , [ FromBody ] GenerateSharedLinkModel model )
2020-02-26 10:01:12 +00:00
{
2020-11-10 10:41:32 +00:00
return FilesControllerHelperString . GenerateSharedLink ( fileId , model . Share ) ;
}
2021-05-05 11:48:15 +00:00
[Update("{fileId}/sharedlink")]
2020-11-10 10:41:32 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public object GenerateSharedLinkFromForm ( string fileId , [ FromForm ] GenerateSharedLinkModel model )
2020-02-26 10:01:12 +00:00
{
2020-11-10 10:41:32 +00:00
return FilesControllerHelperString . GenerateSharedLink ( fileId , model . Share ) ;
2020-03-19 12:56:34 +00:00
}
2020-02-26 10:01:12 +00:00
2020-03-19 12:56:34 +00:00
[Update("{fileId:int}/sharedlink")]
2021-07-09 15:41:07 +00:00
public object GenerateSharedLinkFromBody ( int fileId , [ FromBody ] GenerateSharedLinkModel model )
2020-03-19 12:56:34 +00:00
{
2020-11-10 10:41:32 +00:00
return FilesControllerHelperInt . GenerateSharedLink ( fileId , model . Share ) ;
}
[Update("{fileId:int}/sharedlink")]
[Consumes("application/x-www-form-urlencoded")]
public object GenerateSharedLinkFromForm ( int fileId , [ FromForm ] GenerateSharedLinkModel model )
2020-03-19 12:56:34 +00:00
{
2020-11-10 10:41:32 +00:00
return FilesControllerHelperInt . GenerateSharedLink ( fileId , model . Share ) ;
2020-02-26 10:01:12 +00:00
}
2020-11-30 15:34:45 +00:00
[Update("{fileId:int}/setacelink")]
public bool SetAceLink ( int fileId , [ FromBody ] GenerateSharedLinkModel model )
{
return FilesControllerHelperInt . SetAceLink ( fileId , model . Share ) ;
}
2021-01-13 08:40:11 +00:00
[Update("{fileId}/setacelink")]
public bool SetAceLink ( string fileId , [ FromBody ] GenerateSharedLinkModel model )
{
return FilesControllerHelperString . SetAceLink ( fileId , model . Share ) ;
}
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>
[Create("thirdparty")]
2021-07-09 15:41:07 +00:00
public FolderWrapper < string > SaveThirdPartyFromBody ( [ FromBody ] ThirdPartyModel model )
2020-11-10 10:41:32 +00:00
{
return SaveThirdParty ( model ) ;
}
[Create("thirdparty")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public FolderWrapper < string > SaveThirdPartyFromForm ( [ FromForm ] ThirdPartyModel model )
2020-11-10 10:41:32 +00:00
{
return SaveThirdParty ( model ) ;
}
private FolderWrapper < string > SaveThirdParty ( ThirdPartyModel model )
2020-02-26 10:01:12 +00:00
{
var thirdPartyParams = new ThirdPartyParams
{
2020-11-10 10:41:32 +00:00
AuthData = new AuthData ( model . Url , model . Login , model . Password , model . Token ) ,
Corporate = model . IsCorporate ,
CustomerTitle = model . CustomerTitle ,
ProviderId = model . ProviderId ,
ProviderKey = model . ProviderKey ,
2020-02-26 10:01:12 +00:00
} ;
var folder = FileStorageService . SaveThirdParty ( thirdPartyParams ) ;
return FolderWrapperHelper . Get ( folder ) ;
}
/// <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>
[Read("thirdparty")]
public IEnumerable < ThirdPartyParams > GetThirdPartyAccounts ( )
{
return FileStorageService . GetThirdParty ( ) ;
}
/// <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>
[Read("thirdparty/common")]
2020-07-13 12:57:39 +00:00
public IEnumerable < FolderWrapper < string > > GetCommonThirdPartyFolders ( )
2020-02-26 10:01:12 +00:00
{
2020-03-19 12:56:34 +00:00
var parent = FileStorageServiceInt . GetFolder ( GlobalFolderHelper . FolderCommon ) ;
2020-11-30 13:47:26 +00:00
return EntryManager . GetThirpartyFolders ( parent ) . Select ( r = > FolderWrapperHelper . Get ( r ) ) . ToList ( ) ;
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>
[Delete("thirdparty/{providerId:int}")]
public object DeleteThirdParty ( int providerId )
{
return FileStorageService . DeleteThirdParty ( providerId . ToString ( CultureInfo . InvariantCulture ) ) ;
}
///// <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>
[Create("favorites")]
2021-09-30 06:52:46 +00:00
public bool AddFavoritesFromBody ( [ FromBody ] BaseBatchModel model )
2020-11-06 09:03:49 +00:00
{
return AddFavorites ( model ) ;
}
[Create("favorites")]
[Consumes("application/x-www-form-urlencoded")]
2021-09-30 18:26:01 +00:00
public bool AddFavoritesFromForm ( [ FromForm ] [ ModelBinder ( BinderType = typeof ( BaseBatchModelBinder ) ) ] BaseBatchModel model )
2020-11-06 09:03:49 +00:00
{
return AddFavorites ( model ) ;
}
2021-09-30 06:52:46 +00:00
private bool AddFavorites ( BaseBatchModel model )
2020-09-22 14:17:17 +00:00
{
2021-09-28 15:12:06 +00:00
var ( folderIntIds , folderStringIds ) = FileOperationsManager . GetIds ( model . FolderIds ) ;
var ( fileIntIds , fileStringIds ) = FileOperationsManager . GetIds ( model . FileIds ) ;
FileStorageServiceInt . AddToFavorites ( folderIntIds , fileIntIds ) ;
FileStorageService . AddToFavorites ( folderStringIds , fileStringIds ) ;
2020-09-22 14:17:17 +00:00
return true ;
}
2021-05-26 13:54:46 +00:00
[Read("favorites/{fileId}")]
public bool ToggleFileFavorite ( string fileId , bool favorite )
{
return FileStorageService . ToggleFileFavorite ( fileId , favorite ) ;
}
[Read("favorites/{fileId:int}")]
public bool ToggleFavoriteFromForm ( int fileId , bool favorite )
{
return FileStorageServiceInt . ToggleFileFavorite ( fileId , favorite ) ;
}
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>
[Delete("favorites")]
2021-10-04 17:37:28 +00:00
[Consumes("application/json")]
public bool DeleteFavoritesFromBody ( [ FromBody ] BaseBatchModel model )
{
return DeleteFavorites ( model ) ;
}
[Delete("favorites")]
public bool DeleteFavoritesFromQuery ( [ FromQuery ] [ ModelBinder ( BinderType = typeof ( BaseBatchModelBinder ) ) ] BaseBatchModel model )
{
return DeleteFavorites ( model ) ;
}
private bool DeleteFavorites ( BaseBatchModel model )
2020-09-22 14:17:17 +00:00
{
2021-09-28 15:12:06 +00:00
var ( folderIntIds , folderStringIds ) = FileOperationsManager . GetIds ( model . FolderIds ) ;
var ( fileIntIds , fileStringIds ) = FileOperationsManager . GetIds ( model . FileIds ) ;
FileStorageServiceInt . DeleteFavorites ( folderIntIds , fileIntIds ) ;
FileStorageService . DeleteFavorites ( folderStringIds , fileStringIds ) ;
2020-09-22 14:17:17 +00:00
return true ;
}
/// <summary>
/// Adding files to template list
/// </summary>
/// <short>Template add</short>
/// <category>Files</category>
/// <param name="fileIds">File IDs</param>
/// <returns></returns>
[Create("templates")]
2021-07-09 15:41:07 +00:00
public bool AddTemplatesFromBody ( [ FromBody ] TemplatesModel model )
2020-09-22 14:17:17 +00:00
{
2020-11-10 10:41:32 +00:00
FileStorageServiceInt . AddToTemplates ( model . FileIds ) ;
return true ;
}
[Create("templates")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public bool AddTemplatesFromForm ( [ FromForm ] TemplatesModel model )
2020-09-22 14:17:17 +00:00
{
2020-11-10 10:41:32 +00:00
FileStorageServiceInt . AddToTemplates ( model . FileIds ) ;
2020-09-22 14:17:17 +00:00
return true ;
}
/// <summary>
/// Removing files from template list
/// </summary>
/// <short>Template delete</short>
/// <category>Files</category>
/// <param name="fileIds">File IDs</param>
/// <returns></returns>
[Delete("templates")]
public bool DeleteTemplates ( IEnumerable < int > fileIds )
{
FileStorageServiceInt . DeleteTemplates ( 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")]
2021-07-09 15:41:07 +00:00
public IEnumerable < string > CheckDocServiceUrlFromBody ( [ FromBody ] CheckDocServiceUrlModel model )
2020-02-26 10:01:12 +00:00
{
2020-11-10 10:41:32 +00:00
return CheckDocServiceUrl ( model ) ;
}
[Update("docservice")]
[Consumes("application/x-www-form-urlencoded")]
2021-07-09 15:41:07 +00:00
public IEnumerable < string > CheckDocServiceUrlFromForm ( [ FromForm ] CheckDocServiceUrlModel model )
2020-11-10 10:41:32 +00:00
{
return CheckDocServiceUrl ( model ) ;
}
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>
[Create("thumbnails")]
2021-09-30 06:52:46 +00:00
public IEnumerable < JsonElement > CreateThumbnailsFromBody ( [ FromBody ] BaseBatchModel model )
2021-05-23 16:11:25 +00:00
{
2021-09-24 18:40:29 +00:00
return FileStorageService . CreateThumbnails ( model . FileIds . ToList ( ) ) ;
2021-05-23 16:11:25 +00:00
}
[Create("thumbnails")]
2021-05-30 18:52:32 +00:00
[Consumes("application/x-www-form-urlencoded")]
2021-09-30 18:26:01 +00:00
public IEnumerable < JsonElement > CreateThumbnailsFromForm ( [ FromForm ] [ ModelBinder ( BinderType = typeof ( BaseBatchModelBinder ) ) ] BaseBatchModel model )
2021-05-23 16:11:25 +00:00
{
2021-09-24 18:40:29 +00:00
return FileStorageService . CreateThumbnails ( model . FileIds . ToList ( ) ) ;
2021-05-23 16:11:25 +00:00
}
2021-11-16 17:40:15 +00:00
[Create("masterform/{fileId}/checkfillformdraft")]
public object CheckFillFormDraftFromBody ( string fileId , [ FromBody ] CheckFillFormDraftModel model )
{
return FilesControllerHelperString . CheckFillFormDraft ( fileId , model . Version , model . Doc , ! model . RequestEmbedded , model . RequestView ) ;
}
[Create("masterform/{fileId}/checkfillformdraft")]
[Consumes("application/x-www-form-urlencoded")]
public object CheckFillFormDraftFromForm ( string fileId , [ FromForm ] CheckFillFormDraftModel model )
{
return FilesControllerHelperString . CheckFillFormDraft ( fileId , model . Version , model . Doc , ! model . RequestEmbedded , model . RequestView ) ;
}
[Create("masterform/{fileId:int}/checkfillformdraft")]
public object CheckFillFormDraftFromBody ( int fileId , [ FromBody ] CheckFillFormDraftModel model )
{
return FilesControllerHelperInt . CheckFillFormDraft ( fileId , model . Version , model . Doc , ! model . RequestEmbedded , model . RequestView ) ;
}
[Create("masterform/{fileId:int}/checkfillformdraft")]
[Consumes("application/x-www-form-urlencoded")]
public object CheckFillFormDraftFromForm ( int fileId , [ FromForm ] CheckFillFormDraftModel model )
{
return FilesControllerHelperInt . CheckFillFormDraft ( fileId , model . Version , model . Doc , ! model . RequestEmbedded , model . RequestView ) ;
}
2020-11-10 10:41:32 +00:00
public IEnumerable < string > CheckDocServiceUrl ( 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." ) ;
}
DocumentServiceConnector . CheckDocServiceUrl ( ) ;
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")]
public object GetDocServiceUrl ( bool version )
{
var url = CommonLinkUtility . GetFullAbsolutePath ( FilesLinkUtility . DocServiceApiUrl ) ;
if ( ! version )
{
return url ;
}
var dsVersion = DocumentServiceConnector . GetVersion ( ) ;
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 )
{
if ( model . Code = = "" )
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 ; }
}
}
}