-
Notifications
You must be signed in to change notification settings - Fork 10
#73 - potential fix for HTML mime type support for AEM uploads #165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -78,9 +78,18 @@ class CreateAssetServletUpload extends AEMBinaryUpload { | |
| uploadURIs.push(createAssetServletUrl); | ||
| } | ||
|
|
||
| // Get the file's content type - ensure that HTML files are properly handled | ||
| let contentType = mime.lookup(uploadFile.fileUrl); | ||
|
|
||
| // Check if this is an HTML file - ensure it gets the correct MIME type | ||
| if (uploadFile.fileUrl.toLowerCase().endsWith('.html') || | ||
| (uploadFile.filePath && uploadFile.filePath.toLowerCase().endsWith('.html'))) { | ||
| contentType = 'text/html'; | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, just wondering if we could do this more generally. There are libraries that would help us parse the extension from the file URL, then look up the mime type based on the extension. |
||
|
|
||
| return { | ||
| acceptRanges: true, | ||
| metadata: new AssetMetadata(uploadFile.filePath, mime.lookup(uploadFile.fileUrl), fileSize), | ||
| metadata: new AssetMetadata(uploadFile.filePath, contentType, fileSize), | ||
| nameConflictPolicy: new NameConflictPolicy({ | ||
| versionLabel: uploadFile.versionLabel, | ||
| versionComment: uploadFile.versionComment, | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A couple more places in this file where I wonder if we can handle the content types more generally instead of hard-coding for HTML? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this be safe to do more generally (i.e. remove the
ifstatement and just set the content-type header to whatevertransferPart.contentTypeis)? We could add some safety that only does this if the content-type header isn't explicitly set. I'm just wondering if we'd need to update this block every time a new content type needs to be supported.