public void uploadFile(FileUploadRequest request)
{
DocuRef docuRef = this.createDocuRefFromCommon(request);
DocuActionFile docuActionFile = DocuAction::newDocuRef(docuRef);
str filename, ext, path;
[path,Filename,ext] = fileNameSplit(request.parmFileName());
System.Byte[] messageBytes = System.Convert::FromBase64String(request.parmbase64());
System.IO.MemoryStream memoryStream = new System.IO.MemoryStream(messageBytes);
if(docuRef)
{
docuActionFile.attachFile(docuRef,request.parmFileName(), ext,memoryStream);
}
}
public DocuRef createDocuRefFromCommon(FileUploadRequest req)
{
changecompany('USMF')
{
DocuRef docuRef;
HIQ_dragdrop dragdrop;
select firstonly dragdrop;
docuRef.clear();
docuRef.RefTableId = dragdrop.ReferenceTableId;
docuRef.RefRecId = dragdrop.ReferenceRecId;
docuRef.RefCompanyId = dragdrop.DataAreaId;
docuRef.Name = req.parmFileName();
docuRef.TypeId = "File";
docuRef.insert();
docuRef.reread();
return docuRef;
}
}
and this is where i call my custom service
try
{
const apiResponse = await fetch("https://usnconeboxax1aos.cloud.onebox.dynamics.com/api/services/FileUpload/FileUploadService/UploadFile", {
method: 'POST',
headers: {
'Authorization': `Bearer ${token}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(payload)
});
if (apiResponse.ok) {
console.log("File uploaded successfully");
}
}
catch (error)
{
console.error("fetch error", error);
}
this code is my custom dragdrop contol's javascript code and first time i try to attach the grater than 30 mb file it attach perfectly and i try another time it through 413 error
if you want i will share my full javascript code
and the below is my responce i get
second time try to attach the rebind error is through