Updating app to use Azure Storage blob Containers instead of kentico attachment not working
Overview:
In the past, files were uploaded thru the web app to kentico directly. However, new requirements have come
to "virus scan" the files before upload.
To do this, we reconfiguring kentico so that the storage is azure storage. This will allow azure to scan the files as they are uploaded.
However, when doing so, we are running into issues.
Here is the code inside the webapp.
var postedfile = Helpers.FileHelper.ConstructHttpPostedFile(Helpers.FileHelper.ToByteArray(model.DocFile.InputStream), model.DocFile.FileName, model.DocFile.ContentType);
IUploadedFile uploadedFile = postedfile.ToUploadedFile();
DocumentAttachment ai = DocumentHelper.AddAttachment(kenticofile, "DocFile", uploadedFile);
//ai.Update();
kenticofile.Update(false);
DocumentHelper.UpdateAttachment(kenticofile, kenticofile.Fields.DocFile);
kenticofile.Update(false);
Disclaimer: this code has been thru many iterations trying to fix this problem, so there might be some unnecessary code in here.
We have been following this documentation: https://docs.kentico.com/13api/content-management/attachments
The problem
When uploading a file thru the app, the file gets attached to the kentico field on the page, but the file does not show up in azure.
To fix this, we go to the page in kentico with the attachment, the attachment is showing on the page, we click the "edit" button to edit the image on the page, we don't make any changes, and we then click "save".
After clicking "save" the file shows up in azure storage and download works as expected.
What can be done so we no longer have to go into kentico and "save" the image to make it show up in azure.