Skip to content
This repository has been archived by the owner on Mar 4, 2021. It is now read-only.

Derive mime type from file extension #7

Open
tim-hellhake opened this issue Nov 1, 2019 · 6 comments · May be fixed by #8
Open

Derive mime type from file extension #7

tim-hellhake opened this issue Nov 1, 2019 · 6 comments · May be fixed by #8

Comments

@tim-hellhake
Copy link

It would be nice if the mime type would be derived from the file extension.

@tim-hellhake tim-hellhake linked a pull request Nov 3, 2019 that will close this issue
@tim-hellhake
Copy link
Author

Also discussed in #4

@tim-hellhake
Copy link
Author

@IAmHughes Any thoughts?

@caquino
Copy link

caquino commented Dec 30, 2019

Instead of using the file extension, what about using the mime database to determine the mime type?

I've done a workaround on an action that I'm using the the moment, that looks like:

- name: Build package
  id: build_package
  run: |
   ...
   PACKAGE_MIME=$(file --mime-type ./pkg/${PACKAGE_FILE} | awk '{print $2}')
   echo "::set-output name=content_type:${PACKAGE_MIME}"

- name: Upload release asset
  id: upload-release-asset
  uses: actions/upload-release-asset@v1.0.1
 ..
 with:
 ...
   asset_content_type: ${{ steps.build_package.outputs.content_type }}

Full configuration here

@eine
Copy link

eine commented Dec 30, 2019

@caquino, I'm afraid that the solution you propose might only be valid on GNU/Linux environments (i.e. ubuntu-latest). file --mime-type is unlikely to be available on other platforms.

FTR, it is possible to use a JS package/lib instead: #4 (comment)

@tim-hellhake
Copy link
Author

@caquino

Good idea.

@eine

FTR, it is possible to use a JS package/lib instead: #4 (comment)

Looks good, I'll try that.

@eine
Copy link

eine commented Dec 30, 2019

@tim-hellhake, note that I am not completely happy with my implementation. That's why I didn't explicitly comment about it in #8. See:

https://github.com/eine/tip/blob/a7ad8ec4ef0d919ab02a6f72a507f54e1210a10a/ts/main.ts#L8-L11

https://github.com/eine/tip/blob/a7ad8ec4ef0d919ab02a6f72a507f54e1210a10a/ts/main.ts#L63-L64

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants