Merge remote-tracking branch 'oqtane/dev' into dev
This commit is contained in:
commit
2d66063763
|
@ -329,26 +329,28 @@
|
||||||
var folder = (Folder == Constants.PackagesFolder) ? Folder : FolderId.ToString();
|
var folder = (Folder == Constants.PackagesFolder) ? Folder : FolderId.ToString();
|
||||||
await interop.UploadFiles(posturl, folder, _guid, SiteState.AntiForgeryToken);
|
await interop.UploadFiles(posturl, folder, _guid, SiteState.AntiForgeryToken);
|
||||||
|
|
||||||
// uploading is asynchronous so we need to wait for the uploads to complete
|
// uploading is asynchronous so we need to poll to determine if uploads are completed
|
||||||
// note that this will only wait a maximum of 15 seconds which may not be long enough for very large file uploads
|
var success = true;
|
||||||
bool success = false;
|
int upload = 0;
|
||||||
|
while (upload < uploads.Length && success)
|
||||||
|
{
|
||||||
|
success = false;
|
||||||
|
// note that progressive retry will only wait a maximum of 15 seconds which may not be long enough for very large file uploads
|
||||||
int attempts = 0;
|
int attempts = 0;
|
||||||
while (attempts < 5 && !success)
|
while (attempts < 5 && !success)
|
||||||
{
|
{
|
||||||
attempts += 1;
|
attempts += 1;
|
||||||
Thread.Sleep(1000 * attempts); // progressive retry
|
Thread.Sleep(1000 * attempts); // progressive retry
|
||||||
|
|
||||||
|
var file = await FileService.GetFileAsync(int.Parse(folder), uploads[upload]);
|
||||||
|
if (file != null)
|
||||||
|
{
|
||||||
success = true;
|
success = true;
|
||||||
List<File> files = await FileService.GetFilesAsync(folder);
|
|
||||||
if (files.Count > 0)
|
|
||||||
{
|
|
||||||
foreach (string upload in uploads)
|
|
||||||
{
|
|
||||||
if (!files.Exists(item => item.Name == upload))
|
|
||||||
{
|
|
||||||
success = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (success)
|
||||||
|
{
|
||||||
|
upload++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,14 +381,14 @@
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// set FileId to first file in upload collection
|
// set FileId to first file in upload collection
|
||||||
await GetFiles();
|
var file = await FileService.GetFileAsync(int.Parse(folder), uploads[0]);
|
||||||
var file = _files.Where(item => item.Name == uploads[0]).FirstOrDefault();
|
|
||||||
if (file != null)
|
if (file != null)
|
||||||
{
|
{
|
||||||
FileId = file.FileId;
|
FileId = file.FileId;
|
||||||
await SetImage();
|
await SetImage();
|
||||||
await OnUpload.InvokeAsync(FileId);
|
await OnUpload.InvokeAsync(FileId);
|
||||||
}
|
}
|
||||||
|
await GetFiles();
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace Oqtane.Services
|
||||||
_siteState = siteState;
|
_siteState = siteState;
|
||||||
}
|
}
|
||||||
|
|
||||||
private HttpClient GetHttpClient()
|
public HttpClient GetHttpClient()
|
||||||
{
|
{
|
||||||
if (!_httpClient.DefaultRequestHeaders.Contains(Constants.AntiForgeryTokenHeaderName) && _siteState != null && !string.IsNullOrEmpty(_siteState.AntiForgeryToken))
|
if (!_httpClient.DefaultRequestHeaders.Contains(Constants.AntiForgeryTokenHeaderName) && _siteState != null && !string.IsNullOrEmpty(_siteState.AntiForgeryToken))
|
||||||
{
|
{
|
||||||
|
|
|
@ -138,9 +138,12 @@ namespace Oqtane.Controllers
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (file != null)
|
||||||
{
|
{
|
||||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized File Get Attempt {Name} For Folder {FolderId}", name, folderId);
|
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized File Get Attempt {Name} For Folder {FolderId}", name, folderId);
|
||||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,9 +105,12 @@ namespace Oqtane.Controllers
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (page != null)
|
||||||
{
|
{
|
||||||
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Page Get Attempt {SiteId} {Path}", siteid, path);
|
_logger.Log(LogLevel.Error, this, LogFunction.Security, "Unauthorized Page Get Attempt {SiteId} {Path}", siteid, path);
|
||||||
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
HttpContext.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,8 +180,8 @@ namespace Oqtane.Controllers
|
||||||
page = new Page();
|
page = new Page();
|
||||||
page.SiteId = parent.SiteId;
|
page.SiteId = parent.SiteId;
|
||||||
page.ParentId = parent.PageId;
|
page.ParentId = parent.PageId;
|
||||||
page.Name = user.DisplayName;
|
page.Name = user.Username;
|
||||||
page.Path = parent.Path + "/" + Utilities.GetFriendlyUrl(page.Name);
|
page.Path = parent.Path + "/" + page.Name;
|
||||||
page.Title = page.Name + " - " + parent.Name;
|
page.Title = page.Name + " - " + parent.Name;
|
||||||
page.Order = 0;
|
page.Order = 0;
|
||||||
page.IsNavigation = false;
|
page.IsNavigation = false;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user