2019-06-07 08:59:07 +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.IO;
|
|
|
|
using System.Linq;
|
2019-08-15 12:04:42 +00:00
|
|
|
using System.Text.RegularExpressions;
|
2019-12-09 11:59:22 +00:00
|
|
|
|
2020-02-17 08:58:14 +00:00
|
|
|
using ASC.Common;
|
2019-12-09 11:59:22 +00:00
|
|
|
using ASC.Core.Common.EF;
|
|
|
|
using ASC.Core.Common.EF.Context;
|
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
using Microsoft.Extensions.Configuration;
|
2019-06-07 08:59:07 +00:00
|
|
|
|
|
|
|
namespace ASC.Web.Core.Files
|
|
|
|
{
|
2019-09-23 12:20:08 +00:00
|
|
|
public class FileUtility
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2019-12-09 11:59:22 +00:00
|
|
|
public DbContextManager<FilesDbContext> FilesDbContext { get; set; }
|
2020-02-13 12:19:25 +00:00
|
|
|
public FileUtility(
|
|
|
|
IConfiguration configuration,
|
|
|
|
FilesLinkUtility filesLinkUtility,
|
|
|
|
DbContextManager<FilesDbContext> dbContextManager)
|
2019-09-23 12:20:08 +00:00
|
|
|
{
|
|
|
|
Configuration = configuration;
|
|
|
|
FilesLinkUtility = filesLinkUtility;
|
2019-12-09 11:59:22 +00:00
|
|
|
FilesDbContext = dbContextManager;
|
2020-01-22 13:59:49 +00:00
|
|
|
CanForcesave = GetCanForcesave();
|
2019-09-23 12:20:08 +00:00
|
|
|
}
|
|
|
|
|
2019-06-07 08:59:07 +00:00
|
|
|
#region method
|
|
|
|
|
|
|
|
public static string GetFileExtension(string fileName)
|
|
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(fileName)) return string.Empty;
|
|
|
|
string extension = null;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
extension = Path.GetExtension(fileName);
|
|
|
|
}
|
|
|
|
catch (Exception)
|
|
|
|
{
|
|
|
|
var position = fileName.LastIndexOf('.');
|
|
|
|
if (0 <= position)
|
|
|
|
extension = fileName.Substring(position).Trim().ToLower();
|
|
|
|
}
|
|
|
|
return extension == null ? string.Empty : extension.Trim().ToLower();
|
|
|
|
}
|
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
public string GetInternalExtension(string fileName)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
var extension = GetFileExtension(fileName);
|
2019-08-15 13:05:50 +00:00
|
|
|
return InternalExtension.TryGetValue(GetFileTypeByExtention(extension), out var internalExtension)
|
2019-06-07 08:59:07 +00:00
|
|
|
? internalExtension
|
|
|
|
: extension;
|
|
|
|
}
|
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
public string GetGoogleDownloadableExtension(string googleExtension)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
googleExtension = GetFileExtension(googleExtension);
|
|
|
|
if (googleExtension.Equals(".gdraw")) return ".pdf";
|
|
|
|
return GetInternalExtension(googleExtension);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static string ReplaceFileExtension(string fileName, string newExtension)
|
|
|
|
{
|
|
|
|
newExtension = string.IsNullOrEmpty(newExtension) ? string.Empty : newExtension;
|
|
|
|
return Path.GetFileNameWithoutExtension(fileName) + newExtension;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static FileType GetFileTypeByFileName(string fileName)
|
|
|
|
{
|
|
|
|
return GetFileTypeByExtention(GetFileExtension(fileName));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static FileType GetFileTypeByExtention(string extension)
|
|
|
|
{
|
|
|
|
extension = extension.ToLower();
|
|
|
|
|
|
|
|
if (ExtsDocument.Contains(extension)) return FileType.Document;
|
|
|
|
if (ExtsSpreadsheet.Contains(extension)) return FileType.Spreadsheet;
|
|
|
|
if (ExtsPresentation.Contains(extension)) return FileType.Presentation;
|
|
|
|
if (ExtsImage.Contains(extension)) return FileType.Image;
|
|
|
|
if (ExtsArchive.Contains(extension)) return FileType.Archive;
|
|
|
|
if (ExtsAudio.Contains(extension)) return FileType.Audio;
|
|
|
|
if (ExtsVideo.Contains(extension)) return FileType.Video;
|
|
|
|
|
|
|
|
return FileType.Unknown;
|
|
|
|
}
|
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
public bool CanImageView(string fileName)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
return ExtsImagePreviewed.Contains(GetFileExtension(fileName), StringComparer.CurrentCultureIgnoreCase);
|
|
|
|
}
|
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
public bool CanMediaView(string fileName)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
return ExtsMediaPreviewed.Contains(GetFileExtension(fileName), StringComparer.CurrentCultureIgnoreCase);
|
|
|
|
}
|
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
public bool CanWebView(string fileName)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
return ExtsWebPreviewed.Contains(GetFileExtension(fileName), StringComparer.CurrentCultureIgnoreCase);
|
|
|
|
}
|
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
public bool CanWebEdit(string fileName)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
return ExtsWebEdited.Contains(GetFileExtension(fileName), StringComparer.CurrentCultureIgnoreCase);
|
|
|
|
}
|
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
public bool CanWebReview(string fileName)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
return ExtsWebReviewed.Contains(GetFileExtension(fileName), StringComparer.CurrentCultureIgnoreCase);
|
|
|
|
}
|
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
public bool CanWebRestrictedEditing(string fileName)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
return ExtsWebRestrictedEditing.Contains(GetFileExtension(fileName), StringComparer.CurrentCultureIgnoreCase);
|
|
|
|
}
|
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
public bool CanWebComment(string fileName)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
return ExtsWebCommented.Contains(GetFileExtension(fileName), StringComparer.CurrentCultureIgnoreCase);
|
|
|
|
}
|
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
public bool CanCoAuhtoring(string fileName)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
return ExtsCoAuthoring.Contains(GetFileExtension(fileName), StringComparer.CurrentCultureIgnoreCase);
|
|
|
|
}
|
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
public bool CanIndex(string fileName)
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
return extsIndexing.Contains(GetFileExtension(fileName), StringComparer.CurrentCultureIgnoreCase);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region member
|
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
private Dictionary<string, List<string>> _extsConvertible;
|
2019-06-07 08:59:07 +00:00
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
public Dictionary<string, List<string>> ExtsConvertible
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
if (_extsConvertible == null)
|
|
|
|
{
|
|
|
|
_extsConvertible = new Dictionary<string, List<string>>();
|
|
|
|
if (string.IsNullOrEmpty(FilesLinkUtility.DocServiceConverterUrl)) return _extsConvertible;
|
|
|
|
|
|
|
|
const string databaseId = "files";
|
|
|
|
|
2019-12-09 11:59:22 +00:00
|
|
|
var dbManager = FilesDbContext.Get(databaseId);
|
|
|
|
var list = dbManager.FilesConverts.Select(r => new { r.Input, r.Ouput }).ToList();
|
2019-08-15 15:08:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
list.ForEach(item =>
|
|
|
|
{
|
2019-12-09 11:59:22 +00:00
|
|
|
var input = item.Input;
|
|
|
|
var output = item.Ouput;
|
2019-08-15 15:08:40 +00:00
|
|
|
if (string.IsNullOrEmpty(input) || string.IsNullOrEmpty(output))
|
|
|
|
return;
|
|
|
|
input = input.ToLower().Trim();
|
|
|
|
output = output.ToLower().Trim();
|
|
|
|
if (!_extsConvertible.ContainsKey(input))
|
|
|
|
_extsConvertible[input] = new List<string>();
|
|
|
|
_extsConvertible[input].Add(output);
|
|
|
|
});
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
return _extsConvertible;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
private List<string> _extsUploadable;
|
2019-06-07 08:59:07 +00:00
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
public List<string> ExtsUploadable
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
if (_extsUploadable == null)
|
|
|
|
{
|
|
|
|
_extsUploadable = new List<string>();
|
|
|
|
_extsUploadable.AddRange(ExtsWebPreviewed);
|
|
|
|
_extsUploadable.AddRange(ExtsWebEdited);
|
|
|
|
_extsUploadable.AddRange(ExtsImagePreviewed);
|
|
|
|
_extsUploadable = _extsUploadable.Distinct().ToList();
|
|
|
|
}
|
|
|
|
return _extsUploadable;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
private List<string> extsWebPreviewed { get => (Configuration["files.docservice.viewed-docs"] ?? "").Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); }
|
|
|
|
private List<string> extsWebEdited { get => (Configuration["files.docservice.edited-docs"] ?? "").Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); }
|
|
|
|
private List<string> extsWebReviewed { get => (Configuration["files.docservice.reviewed-docs"] ?? "").Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); }
|
|
|
|
private List<string> extsWebRestrictedEditing { get => (Configuration["files.docservice.formfilling-docs"] ?? "").Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); }
|
|
|
|
private List<string> extsWebCommented { get => (Configuration["files.docservice.commented-docs"] ?? "").Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); }
|
|
|
|
private List<string> extsMustConvert { get => (Configuration["files.docservice.convert-docs"] ?? "").Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); }
|
|
|
|
private List<string> extsIndexing { get => (Configuration["files.index.formats"] ?? "").Split(new[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); }
|
2019-06-07 08:59:07 +00:00
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
public List<string> ExtsImagePreviewed { get => (Configuration["files.viewed-images"] ?? "").Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); }
|
2019-06-07 08:59:07 +00:00
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
public List<string> ExtsMediaPreviewed { get => (Configuration["files.viewed-media"] ?? "").Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); }
|
2019-06-07 08:59:07 +00:00
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
public List<string> ExtsWebPreviewed
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
get { return string.IsNullOrEmpty(FilesLinkUtility.DocServiceApiUrl) ? new List<string>() : extsWebPreviewed; }
|
|
|
|
}
|
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
public List<string> ExtsWebEdited
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
get { return string.IsNullOrEmpty(FilesLinkUtility.DocServiceApiUrl) ? new List<string>() : extsWebEdited; }
|
|
|
|
}
|
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
public List<string> ExtsWebEncrypt { get => (Configuration["files.docservice.encrypted-docs"] ?? "").Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); }
|
2019-06-07 08:59:07 +00:00
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
public List<string> ExtsWebReviewed
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
get { return string.IsNullOrEmpty(FilesLinkUtility.DocServiceApiUrl) ? new List<string>() : extsWebReviewed; }
|
|
|
|
}
|
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
public List<string> ExtsWebRestrictedEditing
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
get { return string.IsNullOrEmpty(FilesLinkUtility.DocServiceApiUrl) ? new List<string>() : extsWebRestrictedEditing; }
|
|
|
|
}
|
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
public List<string> ExtsWebCommented
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
get { return string.IsNullOrEmpty(FilesLinkUtility.DocServiceApiUrl) ? new List<string>() : extsWebCommented; }
|
|
|
|
}
|
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
public List<string> ExtsMustConvert
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
|
|
|
get { return string.IsNullOrEmpty(FilesLinkUtility.DocServiceConverterUrl) ? new List<string>() : extsMustConvert; }
|
|
|
|
}
|
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
public List<string> ExtsCoAuthoring { get => (Configuration["files.docservice.coauthor-docs"] ?? "").Split(new char[] { '|', ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); }
|
|
|
|
public IConfiguration Configuration { get; }
|
|
|
|
public FilesLinkUtility FilesLinkUtility { get; }
|
2019-06-07 08:59:07 +00:00
|
|
|
|
|
|
|
public static readonly List<string> ExtsArchive = new List<string>
|
|
|
|
{
|
|
|
|
".zip", ".rar", ".ace", ".arc", ".arj",
|
|
|
|
".bh", ".cab", ".enc", ".gz", ".ha",
|
|
|
|
".jar", ".lha", ".lzh", ".pak", ".pk3",
|
|
|
|
".tar", ".tgz", ".gz", ".uu", ".uue", ".xxe",
|
|
|
|
".z", ".zoo"
|
|
|
|
};
|
|
|
|
|
|
|
|
public static readonly List<string> ExtsVideo = new List<string>
|
|
|
|
{
|
|
|
|
".3gp", ".asf", ".avi", ".f4v",
|
|
|
|
".fla", ".flv", ".m2ts", ".m4v",
|
|
|
|
".mkv", ".mov", ".mp4", ".mpeg",
|
|
|
|
".mpg", ".mts", ".ogv", ".svi",
|
|
|
|
".vob", ".webm", ".wmv"
|
|
|
|
};
|
|
|
|
|
|
|
|
public static readonly List<string> ExtsAudio = new List<string>
|
|
|
|
{
|
|
|
|
".aac", ".ac3", ".aiff", ".amr",
|
|
|
|
".ape", ".cda", ".flac", ".m4a",
|
|
|
|
".mid", ".mka", ".mp3", ".mpc",
|
|
|
|
".oga", ".ogg", ".pcm", ".ra",
|
|
|
|
".raw", ".wav", ".wma"
|
|
|
|
};
|
|
|
|
|
|
|
|
public static readonly List<string> ExtsImage = new List<string>
|
|
|
|
{
|
|
|
|
".bmp", ".cod", ".gif", ".ief", ".jpe", ".jpeg", ".jpg",
|
|
|
|
".jfif", ".tiff", ".tif", ".cmx", ".ico", ".pnm", ".pbm",
|
|
|
|
".png", ".ppm", ".rgb", ".svg", ".xbm", ".xpm", ".xwd",
|
|
|
|
".svgt", ".svgy", ".gdraw"
|
|
|
|
};
|
|
|
|
|
|
|
|
public static readonly List<string> ExtsSpreadsheet = new List<string>
|
|
|
|
{
|
|
|
|
".xls", ".xlsx", ".xlsm",
|
|
|
|
".xlt", ".xltx", ".xltm",
|
|
|
|
".ods", ".fods", ".ots", ".csv",
|
|
|
|
".xlst", ".xlsy", ".xlsb",
|
|
|
|
".gsheet"
|
|
|
|
};
|
|
|
|
|
|
|
|
public static readonly List<string> ExtsPresentation = new List<string>
|
|
|
|
{
|
|
|
|
".pps", ".ppsx", ".ppsm",
|
|
|
|
".ppt", ".pptx", ".pptm",
|
|
|
|
".pot", ".potx", ".potm",
|
|
|
|
".odp", ".fodp", ".otp",
|
|
|
|
".pptt", ".ppty",
|
|
|
|
".gslides"
|
|
|
|
};
|
|
|
|
|
|
|
|
public static readonly List<string> ExtsDocument = new List<string>
|
|
|
|
{
|
|
|
|
".doc", ".docx", ".docm",
|
|
|
|
".dot", ".dotx", ".dotm",
|
|
|
|
".odt", ".fodt", ".ott", ".rtf", ".txt",
|
|
|
|
".html", ".htm", ".mht",
|
|
|
|
".pdf", ".djvu", ".fb2", ".epub", ".xps",
|
|
|
|
".doct", ".docy",
|
|
|
|
".gdoc"
|
|
|
|
};
|
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
public Dictionary<FileType, string> InternalExtension
|
|
|
|
{
|
|
|
|
get => new Dictionary<FileType, string>
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2019-09-23 12:20:08 +00:00
|
|
|
{ FileType.Document, Configuration["files.docservice.internal-doc"] ?? ".docx" },
|
|
|
|
{ FileType.Spreadsheet, Configuration["files.docservice.internal-xls"] ?? ".xlsx" },
|
|
|
|
{ FileType.Presentation, Configuration["files.docservice.internal-ppt"] ?? ".pptx" }
|
2019-06-07 08:59:07 +00:00
|
|
|
};
|
2019-09-23 12:20:08 +00:00
|
|
|
}
|
2019-06-07 08:59:07 +00:00
|
|
|
|
|
|
|
public enum CsvDelimiter
|
|
|
|
{
|
|
|
|
None = 0,
|
|
|
|
Tab = 1,
|
|
|
|
Semicolon = 2,
|
|
|
|
Colon = 3,
|
|
|
|
Comma = 4,
|
|
|
|
Space = 5
|
|
|
|
}
|
2019-09-23 12:20:08 +00:00
|
|
|
public string SignatureSecret { get => GetSignatureSecret(); }
|
|
|
|
public string SignatureHeader { get => GetSignatureHeader(); }
|
2019-06-07 08:59:07 +00:00
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
private string GetSignatureSecret()
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2019-09-23 12:20:08 +00:00
|
|
|
var result = Configuration["files.docservice.secret"] ?? "";
|
2019-06-07 08:59:07 +00:00
|
|
|
|
|
|
|
var regex = new Regex(@"^\s+$");
|
|
|
|
|
|
|
|
if (regex.IsMatch(result))
|
|
|
|
result = "";
|
|
|
|
|
2019-08-15 12:04:42 +00:00
|
|
|
return result;
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|
|
|
|
|
2019-09-23 12:20:08 +00:00
|
|
|
private string GetSignatureHeader()
|
2019-06-07 08:59:07 +00:00
|
|
|
{
|
2019-09-23 12:20:08 +00:00
|
|
|
var result = (Configuration["files.docservice.secret.header"] ?? "").Trim();
|
2019-06-07 08:59:07 +00:00
|
|
|
if (string.IsNullOrEmpty(result))
|
|
|
|
result = "Authorization";
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2020-01-22 13:59:49 +00:00
|
|
|
public readonly bool CanForcesave;
|
|
|
|
|
|
|
|
private bool GetCanForcesave()
|
|
|
|
{
|
|
|
|
bool canForcesave;
|
|
|
|
return !bool.TryParse(Configuration["files:docservice:forcesave"] ?? "", out canForcesave) || canForcesave;
|
|
|
|
}
|
|
|
|
|
2019-06-07 08:59:07 +00:00
|
|
|
#endregion
|
|
|
|
}
|
2020-02-13 12:19:25 +00:00
|
|
|
|
|
|
|
public static class FileUtilityExtention
|
|
|
|
{
|
2020-02-17 08:58:14 +00:00
|
|
|
public static DIHelper AddFileUtilityService(this DIHelper services)
|
2020-02-13 12:19:25 +00:00
|
|
|
{
|
|
|
|
services.TryAddScoped<FileUtility>();
|
|
|
|
return services
|
|
|
|
.AddFilesLinkUtilityService()
|
|
|
|
.AddFilesDbContextService();
|
|
|
|
}
|
|
|
|
}
|
2019-06-07 08:59:07 +00:00
|
|
|
}
|