2022-03-15 18:00:53 +00:00
// (c) Copyright Ascensio System SIA 2010-2022
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
namespace ASC.Files.Api ;
2022-03-03 17:33:11 +00:00
2022-03-08 17:37:23 +00:00
public class FilesController : ApiControllerBase
2022-03-03 17:33:11 +00:00
{
private readonly IServiceProvider _serviceProvider ;
private readonly GlobalFolderHelper _globalFolderHelper ;
private readonly FileStorageService < string > _fileStorageServiceString ;
2022-03-08 17:43:47 +00:00
private readonly FilesControllerHelper < int > _filesControllerHelperInt ;
private readonly FilesControllerHelper < string > _filesControllerHelperString ;
2022-03-03 17:33:11 +00:00
2022-03-08 17:37:23 +00:00
public FilesController (
2022-03-03 17:33:11 +00:00
IServiceProvider serviceProvider ,
GlobalFolderHelper globalFolderHelper ,
2022-03-08 17:37:23 +00:00
FileStorageService < string > fileStorageServiceString ,
2022-03-08 17:43:47 +00:00
FilesControllerHelper < int > filesControllerHelperInt ,
FilesControllerHelper < string > filesControllerHelperString )
2022-03-03 17:33:11 +00:00
{
_serviceProvider = serviceProvider ;
_globalFolderHelper = globalFolderHelper ;
_fileStorageServiceString = fileStorageServiceString ;
2022-03-08 17:37:23 +00:00
_filesControllerHelperInt = filesControllerHelperInt ;
_filesControllerHelperString = filesControllerHelperString ;
2022-03-03 17:33:11 +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>
[Update("file/{fileId}/history")]
2022-03-05 14:41:47 +00:00
public Task < IEnumerable < FileDto < string > > > ChangeHistoryFromBodyAsync ( string fileId , [ FromBody ] ChangeHistoryRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperString . ChangeHistoryAsync ( fileId , inDto . Version , inDto . ContinueVersion ) ;
2022-03-03 17:33:11 +00:00
}
[Update("file/{fileId:int}/history")]
2022-03-05 14:41:47 +00:00
public Task < IEnumerable < FileDto < int > > > ChangeHistoryFromBodyAsync ( int fileId , [ FromBody ] ChangeHistoryRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperInt . ChangeHistoryAsync ( fileId , inDto . Version , inDto . ContinueVersion ) ;
2022-03-03 17:33:11 +00:00
}
[Update("file/{fileId}/history")]
[Consumes("application/x-www-form-urlencoded")]
2022-03-05 14:41:47 +00:00
public Task < IEnumerable < FileDto < string > > > ChangeHistoryFromFormAsync ( string fileId , [ FromForm ] ChangeHistoryRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperString . ChangeHistoryAsync ( fileId , inDto . Version , inDto . ContinueVersion ) ;
2022-03-03 17:33:11 +00:00
}
[Update("file/{fileId:int}/history")]
[Consumes("application/x-www-form-urlencoded")]
2022-03-05 14:41:47 +00:00
public Task < IEnumerable < FileDto < int > > > ChangeHistoryFromFormAsync ( int fileId , [ FromForm ] ChangeHistoryRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperInt . ChangeHistoryAsync ( fileId , inDto . Version , inDto . ContinueVersion ) ;
2022-03-03 17:33:11 +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>
[Read("file/{fileId}/checkconversion")]
2022-03-04 10:25:12 +00:00
public IAsyncEnumerable < ConversationResultDto < string > > CheckConversionAsync ( string fileId , bool start )
2022-03-03 17:33:11 +00:00
{
2022-03-04 10:25:12 +00:00
return _filesControllerHelperString . CheckConversionAsync ( new CheckConversionRequestDto < string > ( )
2022-03-03 17:33:11 +00:00
{
FileId = fileId ,
StartConvert = start
} ) ;
}
[Read("file/{fileId:int}/checkconversion")]
2022-03-04 10:25:12 +00:00
public IAsyncEnumerable < ConversationResultDto < int > > CheckConversionAsync ( int fileId , bool start )
2022-03-03 17:33:11 +00:00
{
2022-03-04 10:25:12 +00:00
return _filesControllerHelperInt . CheckConversionAsync ( new CheckConversionRequestDto < int > ( )
2022-03-03 17:33:11 +00:00
{
FileId = fileId ,
StartConvert = start
} ) ;
}
[Create("file/{fileId:int}/copyas", order: int.MaxValue - 1)]
2022-03-05 14:41:47 +00:00
public object CopyFileAsFromBody ( int fileId , [ FromBody ] CopyAsRequestDto < JsonElement > inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return CopyFile ( fileId , inDto ) ;
2022-03-03 17:33:11 +00:00
}
[Create("file/{fileId}/copyas", order: int.MaxValue)]
2022-03-05 14:41:47 +00:00
public object CopyFileAsFromBody ( string fileId , [ FromBody ] CopyAsRequestDto < JsonElement > inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return CopyFile ( fileId , inDto ) ;
2022-03-03 17:33:11 +00:00
}
[Create("file/{fileId:int}/copyas", order: int.MaxValue - 1)]
[Consumes("application/x-www-form-urlencoded")]
2022-03-05 14:41:47 +00:00
public object CopyFileAsFromForm ( int fileId , [ FromForm ] CopyAsRequestDto < JsonElement > inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return CopyFile ( fileId , inDto ) ;
2022-03-03 17:33:11 +00:00
}
[Create("file/{fileId}/copyas", order: int.MaxValue)]
[Consumes("application/x-www-form-urlencoded")]
2022-03-05 14:41:47 +00:00
public object CopyFileAsFromForm ( string fileId , [ FromForm ] CopyAsRequestDto < JsonElement > inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return CopyFile ( fileId , inDto ) ;
2022-03-03 17:33:11 +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")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < int > > CreateFileFromBodyAsync ( [ FromBody ] CreateFileRequestDto < JsonElement > inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperInt . CreateFileAsync ( _globalFolderHelper . FolderMy , inDto . Title , inDto . TemplateId , inDto . EnableExternalExt ) ;
2022-03-03 17:33:11 +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>
[Create("{folderId}/file")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < string > > CreateFileFromBodyAsync ( string folderId , [ FromBody ] CreateFileRequestDto < JsonElement > inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperString . CreateFileAsync ( folderId , inDto . Title , inDto . TemplateId , inDto . EnableExternalExt ) ;
2022-03-03 17:33:11 +00:00
}
[Create("{folderId:int}/file")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < int > > CreateFileFromBodyAsync ( int folderId , [ FromBody ] CreateFileRequestDto < JsonElement > inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperInt . CreateFileAsync ( folderId , inDto . Title , inDto . TemplateId , inDto . EnableExternalExt ) ;
2022-03-03 17:33:11 +00:00
}
[Create("@my/file")]
[Consumes("application/x-www-form-urlencoded")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < int > > CreateFileFromFormAsync ( [ FromForm ] CreateFileRequestDto < JsonElement > inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperInt . CreateFileAsync ( _globalFolderHelper . FolderMy , inDto . Title , inDto . TemplateId , inDto . EnableExternalExt ) ;
2022-03-03 17:33:11 +00:00
}
[Create("{folderId}/file")]
[Consumes("application/x-www-form-urlencoded")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < string > > CreateFileFromFormAsync ( string folderId , [ FromForm ] CreateFileRequestDto < JsonElement > inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperString . CreateFileAsync ( folderId , inDto . Title , inDto . TemplateId , inDto . EnableExternalExt ) ;
2022-03-03 17:33:11 +00:00
}
[Create("{folderId:int}/file")]
[Consumes("application/x-www-form-urlencoded")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < int > > CreateFileFromFormAsync ( int folderId , [ FromForm ] CreateFileRequestDto < JsonElement > inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperInt . CreateFileAsync ( folderId , inDto . Title , inDto . TemplateId , inDto . EnableExternalExt ) ;
2022-03-03 17:33:11 +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>
[Create("{folderId}/html")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < string > > CreateHtmlFileFromBodyAsync ( string folderId , [ FromBody ] CreateTextOrHtmlFileRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperString . CreateHtmlFileAsync ( folderId , inDto . Title , inDto . Content ) ;
2022-03-03 17:33:11 +00:00
}
[Create("{folderId:int}/html")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < int > > CreateHtmlFileFromBodyAsync ( int folderId , [ FromBody ] CreateTextOrHtmlFileRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperInt . CreateHtmlFileAsync ( folderId , inDto . Title , inDto . Content ) ;
2022-03-03 17:33:11 +00:00
}
[Create("{folderId}/html")]
[Consumes("application/x-www-form-urlencoded")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < string > > CreateHtmlFileFromFormAsync ( string folderId , [ FromForm ] CreateTextOrHtmlFileRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperString . CreateHtmlFileAsync ( folderId , inDto . Title , inDto . Content ) ;
2022-03-03 17:33:11 +00:00
}
[Create("{folderId:int}/html")]
[Consumes("application/x-www-form-urlencoded")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < int > > CreateHtmlFileFromFormAsync ( int folderId , [ FromForm ] CreateTextOrHtmlFileRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperInt . CreateHtmlFileAsync ( folderId , inDto . Title , inDto . Content ) ;
2022-03-03 17:33:11 +00:00
}
/// <summary>
/// Creates an html (.html) file in 'Common Documents' section with the title and contents sent in the request
/// </summary>
/// <short>Create html in 'Common'</short>
/// <category>File Creation</category>
/// <param name="title">File title</param>
/// <param name="content">File contents</param>
/// <returns>Folder contents</returns>
[Create("@common/html")]
2022-03-05 14:41:47 +00:00
public async Task < FileDto < int > > CreateHtmlFileInCommonFromBodyAsync ( [ FromBody ] CreateTextOrHtmlFileRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return await _filesControllerHelperInt . CreateHtmlFileAsync ( await _globalFolderHelper . FolderCommonAsync , inDto . Title , inDto . Content ) ;
2022-03-03 17:33:11 +00:00
}
[Create("@common/html")]
[Consumes("application/x-www-form-urlencoded")]
2022-03-05 14:41:47 +00:00
public async Task < FileDto < int > > CreateHtmlFileInCommonFromFormAsync ( [ FromForm ] CreateTextOrHtmlFileRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return await _filesControllerHelperInt . CreateHtmlFileAsync ( await _globalFolderHelper . FolderCommonAsync , inDto . Title , inDto . Content ) ;
2022-03-03 17:33:11 +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")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < int > > CreateHtmlFileInMyFromBodyAsync ( [ FromBody ] CreateTextOrHtmlFileRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperInt . CreateHtmlFileAsync ( _globalFolderHelper . FolderMy , inDto . Title , inDto . Content ) ;
2022-03-03 17:33:11 +00:00
}
[Create("@my/html")]
[Consumes("application/x-www-form-urlencoded")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < int > > CreateHtmlFileInMyFromFormAsync ( [ FromForm ] CreateTextOrHtmlFileRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperInt . CreateHtmlFileAsync ( _globalFolderHelper . FolderMy , inDto . Title , inDto . Content ) ;
2022-03-03 17:33:11 +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>
[Create("{folderId}/text")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < string > > CreateTextFileFromBodyAsync ( string folderId , [ FromBody ] CreateTextOrHtmlFileRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperString . CreateTextFileAsync ( folderId , inDto . Title , inDto . Content ) ;
2022-03-03 17:33:11 +00:00
}
[Create("{folderId:int}/text")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < int > > CreateTextFileFromBodyAsync ( int folderId , [ FromBody ] CreateTextOrHtmlFileRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperInt . CreateTextFileAsync ( folderId , inDto . Title , inDto . Content ) ;
2022-03-03 17:33:11 +00:00
}
[Create("{folderId}/text")]
[Consumes("application/x-www-form-urlencoded")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < string > > CreateTextFileFromFormAsync ( string folderId , [ FromForm ] CreateTextOrHtmlFileRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperString . CreateTextFileAsync ( folderId , inDto . Title , inDto . Content ) ;
2022-03-03 17:33:11 +00:00
}
[Create("{folderId:int}/text")]
[Consumes("application/x-www-form-urlencoded")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < int > > CreateTextFileFromFormAsync ( int folderId , [ FromForm ] CreateTextOrHtmlFileRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperInt . CreateTextFileAsync ( folderId , inDto . Title , inDto . Content ) ;
2022-03-03 17:33:11 +00:00
}
/// <summary>
/// Creates a text (.txt) file in 'Common Documents' section with the title and contents sent in the request
/// </summary>
/// <short>Create txt in 'Common'</short>
/// <category>File Creation</category>
/// <param name="title">File title</param>
/// <param name="content">File contents</param>
/// <returns>Folder contents</returns>
[Create("@common/text")]
2022-03-05 14:41:47 +00:00
public async Task < FileDto < int > > CreateTextFileInCommonFromBodyAsync ( [ FromBody ] CreateTextOrHtmlFileRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return await _filesControllerHelperInt . CreateTextFileAsync ( await _globalFolderHelper . FolderCommonAsync , inDto . Title , inDto . Content ) ;
2022-03-03 17:33:11 +00:00
}
[Create("@common/text")]
[Consumes("application/x-www-form-urlencoded")]
2022-03-05 14:41:47 +00:00
public async Task < FileDto < int > > CreateTextFileInCommonFromFormAsync ( [ FromForm ] CreateTextOrHtmlFileRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return await _filesControllerHelperInt . CreateTextFileAsync ( await _globalFolderHelper . FolderCommonAsync , inDto . Title , inDto . Content ) ;
2022-03-03 17:33:11 +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")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < int > > CreateTextFileInMyFromBodyAsync ( [ FromBody ] CreateTextOrHtmlFileRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperInt . CreateTextFileAsync ( _globalFolderHelper . FolderMy , inDto . Title , inDto . Content ) ;
2022-03-03 17:33:11 +00:00
}
[Create("@my/text")]
[Consumes("application/x-www-form-urlencoded")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < int > > CreateTextFileInMyFromFormAsync ( [ FromForm ] CreateTextOrHtmlFileRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperInt . CreateTextFileAsync ( _globalFolderHelper . FolderMy , inDto . Title , inDto . Content ) ;
2022-03-03 17:33:11 +00:00
}
[Create("thumbnails")]
2022-03-05 14:41:47 +00:00
public Task < IEnumerable < JsonElement > > CreateThumbnailsFromBodyAsync ( [ FromBody ] BaseBatchRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _fileStorageServiceString . CreateThumbnailsAsync ( inDto . FileIds . ToList ( ) ) ;
2022-03-03 17:33:11 +00:00
}
[Create("thumbnails")]
[Consumes("application/x-www-form-urlencoded")]
2022-03-05 14:41:47 +00:00
public async Task < IEnumerable < JsonElement > > CreateThumbnailsFromFormAsync ( [ FromForm ] [ ModelBinder ( BinderType = typeof ( BaseBatchModelBinder ) ) ] BaseBatchRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return await _fileStorageServiceString . CreateThumbnailsAsync ( inDto . FileIds . ToList ( ) ) ;
2022-03-03 17:33:11 +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>
[Delete("file/{fileId}", order: int.MaxValue, DisableFormat = true)]
2022-03-05 14:41:47 +00:00
public Task < IEnumerable < FileOperationDto > > DeleteFile ( string fileId , [ FromBody ] DeleteRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperString . DeleteFileAsync ( fileId , inDto . DeleteAfter , inDto . Immediately ) ;
2022-03-03 17:33:11 +00:00
}
[Delete("file/{fileId:int}", order: int.MaxValue - 1, DisableFormat = true)]
2022-03-05 14:41:47 +00:00
public Task < IEnumerable < FileOperationDto > > DeleteFile ( int fileId , [ FromBody ] DeleteRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperInt . DeleteFileAsync ( fileId , inDto . DeleteAfter , inDto . Immediately ) ;
2022-03-03 17:33:11 +00:00
}
[AllowAnonymous]
[Read("file/{fileId}/edit/diff")]
2022-03-04 10:25:12 +00:00
public Task < EditHistoryDataDto > GetEditDiffUrlAsync ( string fileId , int version = 0 , string doc = null )
2022-03-03 17:33:11 +00:00
{
return _filesControllerHelperString . GetEditDiffUrlAsync ( fileId , version , doc ) ;
}
[AllowAnonymous]
[Read("file/{fileId:int}/edit/diff")]
2022-03-04 10:25:12 +00:00
public Task < EditHistoryDataDto > GetEditDiffUrlAsync ( int fileId , int version = 0 , string doc = null )
2022-03-03 17:33:11 +00:00
{
return _filesControllerHelperInt . GetEditDiffUrlAsync ( fileId , version , doc ) ;
}
[AllowAnonymous]
[Read("file/{fileId}/edit/history")]
2022-03-04 10:25:12 +00:00
public Task < List < EditHistoryDto > > GetEditHistoryAsync ( string fileId , string doc = null )
2022-03-03 17:33:11 +00:00
{
return _filesControllerHelperString . GetEditHistoryAsync ( fileId , doc ) ;
}
[AllowAnonymous]
[Read("file/{fileId:int}/edit/history")]
2022-03-04 10:25:12 +00:00
public Task < List < EditHistoryDto > > GetEditHistoryAsync ( int fileId , string doc = null )
2022-03-03 17:33:11 +00:00
{
return _filesControllerHelperInt . GetEditHistoryAsync ( fileId , doc ) ;
}
/// <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>
[Read("file/{fileId}", order: int.MaxValue, DisableFormat = true)]
2022-03-04 10:25:12 +00:00
public Task < FileDto < string > > GetFileInfoAsync ( string fileId , int version = - 1 )
2022-03-03 17:33:11 +00:00
{
return _filesControllerHelperString . GetFileInfoAsync ( fileId , version ) ;
}
[Read("file/{fileId:int}")]
2022-03-04 10:25:12 +00:00
public Task < FileDto < int > > GetFileInfoAsync ( int fileId , int version = - 1 )
2022-03-03 17:33:11 +00:00
{
return _filesControllerHelperInt . GetFileInfoAsync ( fileId , version ) ;
}
/// <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>
[Read("file/{fileId}/history")]
2022-03-04 10:25:12 +00:00
public Task < IEnumerable < FileDto < string > > > GetFileVersionInfoAsync ( string fileId )
2022-03-03 17:33:11 +00:00
{
return _filesControllerHelperString . GetFileVersionInfoAsync ( fileId ) ;
}
[Read("file/{fileId:int}/history")]
2022-03-04 10:25:12 +00:00
public Task < IEnumerable < FileDto < int > > > GetFileVersionInfoAsync ( int fileId )
2022-03-03 17:33:11 +00:00
{
return _filesControllerHelperInt . GetFileVersionInfoAsync ( fileId ) ;
}
[Update("file/{fileId}/lock")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < string > > LockFileFromBodyAsync ( string fileId , [ FromBody ] LockFileRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperString . LockFileAsync ( fileId , inDto . LockFile ) ;
2022-03-03 17:33:11 +00:00
}
[Update("file/{fileId:int}/lock")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < int > > LockFileFromBodyAsync ( int fileId , [ FromBody ] LockFileRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperInt . LockFileAsync ( fileId , inDto . LockFile ) ;
2022-03-03 17:33:11 +00:00
}
[Update("file/{fileId}/lock")]
[Consumes("application/x-www-form-urlencoded")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < string > > LockFileFromFormAsync ( string fileId , [ FromForm ] LockFileRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperString . LockFileAsync ( fileId , inDto . LockFile ) ;
2022-03-03 17:33:11 +00:00
}
[Update("file/{fileId:int}/lock")]
[Consumes("application/x-www-form-urlencoded")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < int > > LockFileFromFormAsync ( int fileId , [ FromForm ] LockFileRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperInt . LockFileAsync ( fileId , inDto . LockFile ) ;
2022-03-03 17:33:11 +00:00
}
[AllowAnonymous]
[Read("file/{fileId}/restoreversion")]
2022-03-04 10:25:12 +00:00
public Task < List < EditHistoryDto > > RestoreVersionAsync ( string fileId , int version = 0 , string url = null , string doc = null )
2022-03-03 17:33:11 +00:00
{
return _filesControllerHelperString . RestoreVersionAsync ( fileId , version , url , doc ) ;
}
[AllowAnonymous]
[Read("file/{fileId:int}/restoreversion")]
2022-03-04 10:25:12 +00:00
public Task < List < EditHistoryDto > > RestoreVersionAsync ( int fileId , int version = 0 , string url = null , string doc = null )
2022-03-03 17:33:11 +00:00
{
return _filesControllerHelperInt . RestoreVersionAsync ( fileId , version , url , doc ) ;
}
/// <summary>
/// Start conversion
/// </summary>
/// <short>Convert</short>
/// <category>File operations</category>
/// <param name="fileId"></param>
/// <returns>Operation result</returns>
[Update("file/{fileId}/checkconversion")]
2022-03-05 14:41:47 +00:00
public IAsyncEnumerable < ConversationResultDto < string > > StartConversion ( string fileId , [ FromBody ( EmptyBodyBehavior = Microsoft . AspNetCore . Mvc . ModelBinding . EmptyBodyBehavior . Allow ) ] CheckConversionRequestDto < string > inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
if ( inDto = = null )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
inDto = new CheckConversionRequestDto < string > ( ) ;
2022-03-03 17:33:11 +00:00
}
2022-03-05 14:41:47 +00:00
inDto . FileId = fileId ;
2022-03-08 17:37:23 +00:00
2022-03-05 14:41:47 +00:00
return _filesControllerHelperString . StartConversionAsync ( inDto ) ;
2022-03-03 17:33:11 +00:00
}
[Update("file/{fileId:int}/checkconversion")]
2022-03-05 14:41:47 +00:00
public IAsyncEnumerable < ConversationResultDto < int > > StartConversion ( int fileId , [ FromBody ( EmptyBodyBehavior = Microsoft . AspNetCore . Mvc . ModelBinding . EmptyBodyBehavior . Allow ) ] CheckConversionRequestDto < int > inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
if ( inDto = = null )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
inDto = new CheckConversionRequestDto < int > ( ) ;
2022-03-03 17:33:11 +00:00
}
2022-03-05 14:41:47 +00:00
inDto . FileId = fileId ;
return _filesControllerHelperInt . StartConversionAsync ( inDto ) ;
2022-03-03 17:33:11 +00:00
}
[Update("file/{fileId}/comment")]
2022-03-05 14:41:47 +00:00
public async Task < object > UpdateCommentFromBodyAsync ( string fileId , [ FromBody ] UpdateCommentRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return await _filesControllerHelperString . UpdateCommentAsync ( fileId , inDto . Version , inDto . Comment ) ;
2022-03-03 17:33:11 +00:00
}
[Update("file/{fileId:int}/comment")]
2022-03-05 14:41:47 +00:00
public async Task < object > UpdateCommentFromBodyAsync ( int fileId , [ FromBody ] UpdateCommentRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return await _filesControllerHelperInt . UpdateCommentAsync ( fileId , inDto . Version , inDto . Comment ) ;
2022-03-03 17:33:11 +00:00
}
[Update("file/{fileId}/comment")]
[Consumes("application/x-www-form-urlencoded")]
2022-03-05 14:41:47 +00:00
public async Task < object > UpdateCommentFromFormAsync ( string fileId , [ FromForm ] UpdateCommentRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return await _filesControllerHelperString . UpdateCommentAsync ( fileId , inDto . Version , inDto . Comment ) ;
2022-03-03 17:33:11 +00:00
}
[Update("file/{fileId:int}/comment")]
[Consumes("application/x-www-form-urlencoded")]
2022-03-05 14:41:47 +00:00
public async Task < object > UpdateCommentFromFormAsync ( int fileId , [ FromForm ] UpdateCommentRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return await _filesControllerHelperInt . UpdateCommentAsync ( fileId , inDto . Version , inDto . Comment ) ;
2022-03-03 17:33:11 +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>
[Update("file/{fileId}", order: int.MaxValue, DisableFormat = true)]
2022-03-05 14:41:47 +00:00
public Task < FileDto < string > > UpdateFileFromBodyAsync ( string fileId , [ FromBody ] UpdateFileRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperString . UpdateFileAsync ( fileId , inDto . Title , inDto . LastVersion ) ;
2022-03-03 17:33:11 +00:00
}
[Update("file/{fileId:int}", order: int.MaxValue - 1, DisableFormat = true)]
2022-03-05 14:41:47 +00:00
public Task < FileDto < int > > UpdateFileFromBodyAsync ( int fileId , [ FromBody ] UpdateFileRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperInt . UpdateFileAsync ( fileId , inDto . Title , inDto . LastVersion ) ;
2022-03-03 17:33:11 +00:00
}
[Update("file/{fileId}", order: int.MaxValue, DisableFormat = true)]
[Consumes("application/x-www-form-urlencoded")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < string > > UpdateFileFromFormAsync ( string fileId , [ FromForm ] UpdateFileRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperString . UpdateFileAsync ( fileId , inDto . Title , inDto . LastVersion ) ;
2022-03-03 17:33:11 +00:00
}
[Update("file/{fileId:int}", order: int.MaxValue - 1, DisableFormat = true)]
[Consumes("application/x-www-form-urlencoded")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < int > > UpdateFileFromFormAsync ( int fileId , [ FromForm ] UpdateFileRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperInt . UpdateFileAsync ( fileId , inDto . Title , inDto . LastVersion ) ;
2022-03-03 17:33:11 +00:00
}
/// <summary>
///
/// </summary>
/// <param name="file"></param>
/// <param name="fileId"></param>
/// <param name="encrypted"></param>
/// <returns></returns>
/// <visible>false</visible>
[Update("{fileId}/update")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < string > > UpdateFileStreamFromFormAsync ( string fileId , [ FromForm ] FileStreamRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperString . UpdateFileStreamAsync ( _filesControllerHelperInt . GetFileFromRequest ( inDto ) . OpenReadStream ( ) , fileId , inDto . FileExtension , inDto . Encrypted , inDto . Forcesave ) ;
2022-03-03 17:33:11 +00:00
}
[Update("{fileId:int}/update")]
2022-03-05 14:41:47 +00:00
public Task < FileDto < int > > UpdateFileStreamFromFormAsync ( int fileId , [ FromForm ] FileStreamRequestDto inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return _filesControllerHelperInt . UpdateFileStreamAsync ( _filesControllerHelperInt . GetFileFromRequest ( inDto ) . OpenReadStream ( ) , fileId , inDto . FileExtension , inDto . Encrypted , inDto . Forcesave ) ;
2022-03-03 17:33:11 +00:00
}
2022-03-05 14:41:47 +00:00
private object CopyFile < T > ( T fileId , CopyAsRequestDto < JsonElement > inDto )
2022-03-03 17:33:11 +00:00
{
2022-03-08 17:43:47 +00:00
var helper = _serviceProvider . GetService < FilesControllerHelper < T > > ( ) ;
2022-03-05 14:41:47 +00:00
if ( inDto . DestFolderId . ValueKind = = JsonValueKind . Number )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return helper . CopyFileAsAsync ( fileId , inDto . DestFolderId . GetInt32 ( ) , inDto . DestTitle , inDto . Password ) ;
2022-03-03 17:33:11 +00:00
}
2022-03-05 14:41:47 +00:00
else if ( inDto . DestFolderId . ValueKind = = JsonValueKind . String )
2022-03-03 17:33:11 +00:00
{
2022-03-05 14:41:47 +00:00
return helper . CopyFileAsAsync ( fileId , inDto . DestFolderId . GetString ( ) , inDto . DestTitle , inDto . Password ) ;
2022-03-03 17:33:11 +00:00
}
return null ;
}
}