fixed ChunkedUploader with external uploader url
This commit is contained in:
parent
212a38acc8
commit
887926f852
@ -24,6 +24,8 @@
|
||||
// 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
|
||||
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace ASC.Web.Files.HttpHandlers;
|
||||
|
||||
public class ChunkedUploaderHandler
|
||||
@ -83,11 +85,7 @@ public class ChunkedUploaderHandlerService
|
||||
{
|
||||
try
|
||||
{
|
||||
var uploadSession = await _chunkedUploadSessionHolder.GetSessionAsync<int>(context.Request.Query["uid"]);
|
||||
if (uploadSession != null)
|
||||
{
|
||||
await Invoke<int>(context);
|
||||
}
|
||||
await Invoke<int>(context);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
@ -306,12 +304,38 @@ public class ChunkedRequestHelper<T>
|
||||
return _authKey.Value;
|
||||
}
|
||||
|
||||
public T FolderId => (T)Convert.ChangeType(_request.Query[FilesLinkUtility.FolderId], typeof(T));
|
||||
|
||||
public T FileId => (T)Convert.ChangeType(_request.Query[FilesLinkUtility.FileId], typeof(T));
|
||||
|
||||
public T FolderId
|
||||
{
|
||||
get
|
||||
{
|
||||
var queryValue = _request.Query[FilesLinkUtility.FolderId];
|
||||
|
||||
if (queryValue.Count == 0)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
return (T)Convert.ChangeType(queryValue[0], typeof(T));
|
||||
}
|
||||
}
|
||||
|
||||
public T FileId
|
||||
{
|
||||
get
|
||||
{
|
||||
var queryValue = _request.Query[FilesLinkUtility.FileId];
|
||||
|
||||
if (queryValue.Count == 0)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
|
||||
return (T)Convert.ChangeType(queryValue[0], typeof(T));
|
||||
}
|
||||
}
|
||||
|
||||
public string FileName => _request.Query[FilesLinkUtility.FileTitle];
|
||||
|
||||
|
||||
public long FileSize
|
||||
{
|
||||
get
|
||||
@ -337,17 +361,24 @@ public class ChunkedRequestHelper<T>
|
||||
return _cultureInfo;
|
||||
}
|
||||
|
||||
var culture = _request.Query["culture"];
|
||||
if (string.IsNullOrEmpty(culture))
|
||||
var queryValue = _request.Query["culture"];
|
||||
|
||||
string culture;
|
||||
|
||||
if (queryValue.Count == 0)
|
||||
{
|
||||
culture = "en-US";
|
||||
}
|
||||
else
|
||||
{
|
||||
culture = queryValue[0];
|
||||
}
|
||||
|
||||
return _cultureInfo = setupInfo.GetPersonalCulture(culture).Value;
|
||||
}
|
||||
|
||||
public bool Encrypted => _request.Query["encrypted"] == "true";
|
||||
|
||||
|
||||
private IFormFile File
|
||||
{
|
||||
get
|
||||
|
@ -24,6 +24,10 @@
|
||||
// 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
|
||||
|
||||
using Amqp;
|
||||
|
||||
using ICSharpCode.SharpZipLib.Core;
|
||||
|
||||
namespace ASC.Files.Helpers;
|
||||
|
||||
public class UploadControllerHelper<T> : FilesHelperBase<T>
|
||||
@ -115,8 +119,26 @@ public class UploadControllerHelper<T> : FilesHelperBase<T>
|
||||
using var response = await httpClient.SendAsync(request);
|
||||
using var responseStream = await response.Content.ReadAsStreamAsync();
|
||||
using var streamReader = new StreamReader(responseStream);
|
||||
|
||||
return JObject.Parse(await streamReader.ReadToEndAsync()); //result is json string
|
||||
|
||||
var responseAsString = await streamReader.ReadToEndAsync();
|
||||
var jObject = JObject.Parse(responseAsString); //result is json string
|
||||
|
||||
var result = new
|
||||
{
|
||||
success = jObject["success"].ToString(),
|
||||
data = new
|
||||
{
|
||||
id = jObject["data"]["id"].ToString(),
|
||||
path = jObject["data"]["path"].Values().Select(x => (T)Convert.ChangeType(x, typeof(T))),
|
||||
created = jObject["data"]["created"].Value<DateTime>(),
|
||||
expired = jObject["data"]["expired"].Value<DateTime>(),
|
||||
location = jObject["data"]["location"].ToString(),
|
||||
bytes_uploaded = jObject["data"]["bytes_uploaded"].Value<long>(),
|
||||
bytes_total = jObject["data"]["bytes_total"].Value<long>()
|
||||
}
|
||||
};
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<object> UploadFileAsync(T folderId, UploadRequestDto uploadModel)
|
||||
|
Loading…
Reference in New Issue
Block a user