microsoft / msix-packaging

MSIX SDK
MIT License
964 stars 163 forks source link

[Question] What is the payload file content type used for? #494

Closed MarkIngramUK closed 4 months ago

MarkIngramUK commented 2 years ago

What is the payload file content used for in an MSIX, and is it important that the type uses the most accurate value (e.g. image/jpeg for a JPEG, rather than application/octet-stream)?

anarvekar-msft commented 2 years ago

Thank you for your question. Payload files are all the files specific to your application that are in the msix package, whatever files you need to run your application - javascript files, image files etc.

When the MSIX package is created via makemsix or makeappx we have an internal map that correlates the file extension to its content type and default compression option. For makemsix this is the map https://github.com/microsoft/msix-packaging/blob/c8af99506ffd0c1513fad39cdadfac281723c3e3/src/msix/pack/ContentType.cpp

If you create your MSIX via the AppxPackaging APIs, you can specify your preferred content type and compression option. It doesn't have a huge impact, but we recommend using the most accurate value as possible.

MarkIngramUK commented 2 years ago

Thanks for the response @anarvekar-msft . We're using the packaging APIs, so I guess my confusion comes from having to specify both a content type and a compression option to IAppxPackageWriter::AddPayloadFile.

Looking at https://github.com/microsoft/msix-packaging/blob/c8af99506ffd0c1513fad39cdadfac281723c3e3/src/msix/pack/AppxPackageWriter.cpp#L162 I can see several checks for if (contentType != nullptr), so I think we should be fine to pass a nullptr for the contentType param of AddPayloadFile, despite the docs not listing it as an optional param. That would avoid us also having a similar map of filename extension to content type (in order to pass the "correct" content type through to AddPayloadFile). Is that OK?