Skip to content
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

Mp3 files get converted to Mpga #371

Open
wahidshafique opened this issue Nov 30, 2021 · 3 comments
Open

Mp3 files get converted to Mpga #371

wahidshafique opened this issue Nov 30, 2021 · 3 comments

Comments

@wahidshafique
Copy link

I logged this issue here https://community.airtable.com/t/why-are-my-mp3-files-being-converted-to-mpga-when-downloaded-through-the-api/44200 thinking that it was a bug within Airtable itself, however now it seems as if this is caused by gatsby-source-airtable. I added a log point here

const ext = mime.getExtension(attachment.type); // unknown type returns null
and noticed that all my mp3 files were coming in as mpga. Is there a particular reason for this?

@wahidshafique
Copy link
Author

I think its actually the mime package itself that causes the mismatch, so perhaps its worth refining the approach here. I'm not exactly sure how the original commenter of that issue resolved it.

wahidshafique added a commit to wahidshafique/gatsby-source-airtable that referenced this issue Dec 7, 2021
This is an attempt to rectify jbolda#371 This fix ensures that the file extension does not get changed when we pull from airtable.
@jbolda
Copy link
Owner

jbolda commented Dec 13, 2021

Is the filename extension actually changed when it downloads or is it how gatsby processes and considers it?

@wahidshafique
Copy link
Author

wahidshafique commented Dec 13, 2021

I think its how gatsby processes it and here was my ad-hoc fix

diff --git a/node_modules/gatsby-source-airtable/gatsby-node.js b/node_modules/gatsby-source-airtable/gatsby-node.js
index bdd512b..39e131f 100644
--- a/node_modules/gatsby-source-airtable/gatsby-node.js
+++ b/node_modules/gatsby-source-airtable/gatsby-node.js
@@ -304,7 +304,10 @@ const localFileCheck = async (
       // `data` is direct from Airtable so we don't use
       // the cleanKey here
       data[key].forEach((attachment) => {
-        const ext = mime.getExtension(attachment.type); // unknown type returns null
+        let ext = mime.getExtension(attachment.type); // unknown type returns null
+        if (ext === 'mpga') {
+          ext = 'mp3'
+        }
         let attachmentNode = createRemoteFileNode({
           url: attachment.url,
           store,

it seems to change only when its used in conjunction with the mime type package, nothing from Gatbsy or Airtable suggests that theres a transformation going on before that. Once there is a mismatch Gatsby completely forgets about the new mpga (I guess because it does not exist)

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

No branches or pull requests

2 participants