web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to set content type of file uploaded to temporary storage

(0) ShareShare
ReportReport
Posted on by 5

Hello,

In Ax 2012 I could use AifXmlViewer::construct(my_xml, AifXmlType::XML).show() to display xml content. I can't do that in D365FO. I find out the WebsiteHostControl can display xml in similar way but I need to pass the URL to that file. It works only if its ContentType is Application/XML or Text/XML. The problem is where I'm using File::GetFileFromUser(classstr(XMLFileUploadTemporaryStorageStrategy)) or even uploadStrategy.uploadFile(stream, 'MyFile.xml', 'application/xml') the uploaded file has always Content Type "application/octet-stream".

So my question is what is the simplest method to upload file with 'application/xml' content type to default D365 temporary storage or what is the best method to show xml with collapsible sections and colored texts similarly to AifXmlViewer?

I have the same question (0)
  • Suggested answer
    huijij Profile Picture
    19,811 on at

    Hi D365FODev1231223,

    Do you mean you want to set the content type of the file of 'application/xml' to the default D365 temporary storage? The file upload control lets users upload a file in D365fo. It also lets developers control the upload process and manage the file that is uploaded, based on their requirements. The FileTypesAccepted property of the file upload control lets you limit the types of files that users can upload. The file types that users can upload are primarily controlled by the associated upload strategy.

    learn.microsoft.com/.../file-upload-control

  • D365FODev1231223 Profile Picture
    5 on at

    Hello Judy,

    I will explain it better. Currently I'm using the code below to upload my file to temporary storage.

    FileUploadTemporaryStorageStrategy uploadStrategy = new XMLFileUploadTemporaryStorageStrategy();
    FileUploadTemporaryStorageResult result = uploadStrategy.uploadFile(stream, 'MyFile.xml', 'application/xml') as FileUploadTemporaryStorageResult;

    As you can see I'm using xml upload strategy. One of the argument of upload method is ContentType. But unfortunately it doesn't matter what I put here, the result is always same - when I start Azure Storage Explorer I can see the Content Type of uploaded file is application/octet-stream.
    OctetStream.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 584 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 499 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 254 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans