Why am I not able to view and upload media to Netlify Large Media via Netlify CMS?

I’m trying to setup Netlify Large Media to work with my Netlify CMS configuration. The media in the repo was uploaded OK via Git LFS, however when trying to view media inside Netlify CMS nothing displays.

My best guess was that something was wrong with Netlify Git Gateway - however that’s all setup with a GitHub API token. I’m assuming Netlify automatically uses that token and nothing is needed on my end, however.
My config.yml is as follows:

  name: git-gateway

media_folder: "static/img"
public_folder: "/img"

When opening up Netlify CMS, I get a TypeError in the console:

mediaLibrary.js:230 TypeError: Cannot read property 'map' of undefined
    at S (netlify-lfs-client.js:158)
    at Object.getResourceDownloadURLArgs (netlify-lfs-client.js:239)
    at implementation.js:374
    at /admin/async https:/unpkg.com/netlify-cms@2.9.7/dist/netlify-cms.js:234
(anonymous) @ mediaLibrary.js:230

If I try to upload an image I get another TypeError :

Uncaught (in promise) TypeError: Cannot read property 'find' of undefined
    at mediaLibrary.js:246
    at index.js:8
    at redux.js:462
    at MediaLibrary.js:145
    at Object.<anonymous> (react-dom.production.min.js:14)
    at f (react-dom.production.min.js:15)
    at react-dom.production.min.js:15
    at S (react-dom.production.min.js:17)
    at k (react-dom.production.min.js:18)
    at T (react-dom.production.min.js:18)

It could very well be a bug in Netlify itself - though I doubt it, as I suspect this use-case is very common. My repository is open-sourced at https://github.com/MichaelDono/michaeldono.com/

I tried using gatsby-plugin-netlify-cms instead of the static page in an admin folder - now I get the same error, only from a different JS source:

TypeError: Cannot read property 'map' of undefined
    at T (netlify-cms-app.js:209)
    at Object.getResourceDownloadURLArgs (netlify-cms-app.js:209)
    at netlify-cms-app.js:209

If I pretty print the minified file the problem seems to originate in the async function getLargeMediaDisplayURLs in netlify-cms-app.js, particularly here:

return Promise.all([n, t.getResourceDownloadURLArgs(r).then(s.default)])

I’m really running out of ideas now :frowning:

Thanks in advance

Hey Michael! This looks like a potential bug in Netlify CMS, would you mind opening an issue on the repo? https://github.com/netlify/netlify-cms/issues/new

1 Like

I managed to find the source of the error - I had my images in png/ and img/ folders within the media library directory. I happened to upload an image at the media library root and it showed up in the CMS.

Is it intended behaviour to only retrieve images at the root of the media library? Just wanted to check before I open an issue :slight_smile:

1 Like

thanks for keeping us posted! this might also help out other users as well :muscle: