|
@@ -86,6 +86,13 @@ namespace TEAMModelOS.Controllers
|
|
|
//if (!jwt.Payload.Iss.Equals("account.teammodel", StringComparison.OrdinalIgnoreCase)) return BadRequest();
|
|
|
//var id = jwt.Payload.Sub;
|
|
|
var (id, _, _, school) = HttpContext.GetAuthTokenInfo();
|
|
|
+ var containerid = id;
|
|
|
+ if (request.TryGetProperty("scope", out JsonElement jscope)) {
|
|
|
+ if (jscope.GetString().Equals("school"))
|
|
|
+ {
|
|
|
+ containerid = school;
|
|
|
+ }
|
|
|
+ }
|
|
|
request.TryGetProperty("file", out JsonElement code);
|
|
|
string azureBlobSAS = System.Web.HttpUtility.UrlDecode(code.ToString(), Encoding.UTF8);
|
|
|
(string, string) a = BlobUrlString(azureBlobSAS);
|
|
@@ -105,7 +112,7 @@ namespace TEAMModelOS.Controllers
|
|
|
|
|
|
if (ext.ToLower() == "pptx" || ext.ToLower() == "xml")
|
|
|
{
|
|
|
- string index = await PPTXTranslator(id, FileName, stream);
|
|
|
+ string index = await PPTXTranslator(containerid, FileName, stream);
|
|
|
return Ok(new { index = index });
|
|
|
}
|
|
|
else if (ext.ToLower() == "docx" || ext.ToLower() == "doc")
|
|
@@ -155,8 +162,6 @@ namespace TEAMModelOS.Controllers
|
|
|
{
|
|
|
return BadRequest("type is not pptx or xml !");
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -213,12 +218,12 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
|
|
|
|
|
|
- private async Task<string> PPTXTranslator(string id, string FileName, Stream streamFile)
|
|
|
+ private async Task<string> PPTXTranslator(string containerid, string FileName, Stream streamFile)
|
|
|
{
|
|
|
- if (string.IsNullOrWhiteSpace(id)) {
|
|
|
- id = "teammodelos";
|
|
|
+ if (string.IsNullOrWhiteSpace(containerid)) {
|
|
|
+ containerid = "teammodelos";
|
|
|
}
|
|
|
- var status = await _azureStorage.GetBlobServiceClient().DelectBlobs(id, $"res/{FileName}");
|
|
|
+ var status = await _azureStorage.GetBlobServiceClient().DelectBlobs(containerid, $"res/{FileName}");
|
|
|
|
|
|
string shaCode = Guid.NewGuid().ToString();
|
|
|
HTEXLib.Htex htex = _PPTX2HTEXTranslator.Translate(streamFile);
|
|
@@ -238,7 +243,7 @@ namespace TEAMModelOS.Controllers
|
|
|
foreach (var key in blobslidenames)
|
|
|
{
|
|
|
slds.Add(new Sld { type = "normal", url = $"{key.Key}.json", scoring = null }); ;
|
|
|
- tasks.Add(_azureStorage.UploadFileByContainer(id, key.Value, "res", $"{FileName}/{key.Key}.json" , false));
|
|
|
+ tasks.Add(_azureStorage.UploadFileByContainer(containerid, key.Value, "res", $"{FileName}/{key.Key}.json" , false));
|
|
|
}
|
|
|
await Task.WhenAll(tasks);
|
|
|
// Dictionary<string, Store> dict = new Dictionary<string, Store>();
|
|
@@ -259,7 +264,7 @@ namespace TEAMModelOS.Controllers
|
|
|
// var urlstrs = key.Split("/");
|
|
|
var name = key.Replace("/","");
|
|
|
str.url = $"{name}";
|
|
|
- tasksFiles.Add(_azureStorage.UploadFileByContainer(id, stream, "res", $"{FileName}/{name}", false));
|
|
|
+ tasksFiles.Add(_azureStorage.UploadFileByContainer(containerid, stream, "res", $"{FileName}/{name}", false));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -270,7 +275,7 @@ namespace TEAMModelOS.Controllers
|
|
|
await Task.WhenAll(tasksFiles);
|
|
|
// index.stores = dict;
|
|
|
index.slides = slds;
|
|
|
- var BlobUrl = await _azureStorage.UploadFileByContainer(id, JsonHelper.ToJson(index, ignoreNullValue: false), "res", FileName + "/" + "index.json", false);
|
|
|
+ var BlobUrl = await _azureStorage.UploadFileByContainer(containerid, JsonHelper.ToJson(index, ignoreNullValue: false), "res", FileName + "/" + "index.json", false);
|
|
|
return System.Web.HttpUtility.UrlDecode(BlobUrl, Encoding.UTF8);
|
|
|
}
|
|
|
}
|