decaporg / decap-cms

A Git-based CMS for Static Site Generators
https://decapcms.org
MIT License
17.93k stars 3.04k forks source link

Upload fails if media folder does not exist #2264

Closed tamasfilkor closed 5 years ago

tamasfilkor commented 5 years ago

I can not upload files in the content manager. I use Bitbucket and get an error:

Screenshot from 2019-04-02 21-14-52

erquhart commented 5 years ago

We need more info to really be helpful here. Can you provide your config, or a link to the repo if it's public?

arminnaimi commented 5 years ago

I am having the same issue. Below is a detailed bug report:

Describe the bug

Every time I try to upload an image in the editor and from the top navigation. I received the error in the screenshot:

To Reproduce

Open the media gallery Upload image

Expected behavior

When uploading an image, the image should appear in the media gallery.

Applicable Versions:

netlify-cms 2.9.0 GitLab.com Safari, Chrome OS X Mojave Node v10.15.3 on Netlify (using Netlify Large Media)

CMS configuration:

backend:
  name: git-gateway
  branch: master # Branch to update (optional; defaults to master)

media_folder: "static/media/uploads"
public_folder: "/media/uploads"
logo_url: https://redacted.com/image.png

collections:
  - name: "aktuelles" # Used in routes, e.g., /admin/collections/blog
    label: "Aktuelles Artikel" # Used in the UI
    file: "markdown"
    folder: "/src/posts/" # The path to the folder where the documents are stored
    create: true # Allow users to create new documents in this collection
    slug: "{{slug}}" # Filename template, e.g., YYYY-MM-DD-title.md
    fields: # The fields for each document, usually in front matter
      - {label: "Title", name: "title", widget: "string"}
      - {label: "Publish Date", name: "date", widget: "date", format: "DD. MMMM YYYY"}
      - {label: "Description", name: "description", widget: "string", required: false }
      - {label: "Featured Image", name: "feature_image", widget: "image", required: false }
      - {label: "Categories", name: "categories", widget: "select", multiple: true, options: ["Redacted"], required: false }
      - {label: "Body", name: "body", widget: "markdown"}
arminnaimi commented 5 years ago

I just figured what the issue is. In my case the media folder did not exist, as I did not add any images. After adding a single image to the media folder and pushing to the repo, it all works as expected.

tamasfilkor commented 5 years ago

Sorry for I did not wrote any details and my late response, but here is my config.yml file:

backend:
  name: bitbucket
  repo: filkordev/beresautosiskola

media_folder: static/assets
public_folder: assets

site_url: https://blissful-carson-3f4906.netlify.com

collections:
  - name: home
    label: Főoldal szöveg
    folder: content/home
    create: false
    fields:
      - { name: title, label: Cím }
      - { name: body, label: Szöveg, widget: markdown }
  - name: about
    label: Iskolánkról
    folder: content/about
    create: false
    fields:
      - { name: title, label: Cím }
      - { name: body, label: Szöveg, widget: markdown }
  - name: course
    label: Tanfolyam
    folder: content/course
    create: true
    fields:
      - { name: title, label: Név, widget: string }
      - { name: date, label: Dátum, widget: date }
  - name: teachers
    label: Oktatók
    folder: content/teachers
    create: true
    identifier_field: phone
    fields:
      - { name: name, label: Név, widget: string }
      - { name: phone, label: Telefonszám, widget: string }
      - { name: car, label: Autó, widget: string }
  - name: prices
    label: Árak
    folder: content/prices
    create: true
    identifier_field: name
    fields:
      - {
          name: category,
          label: Kategória,
          widget: select,
          options: ['A', 'B'],
          default: 'B',
        }
      - {
          name: type,
          label: Típus,
          widget: select,
          options: ['normál', 'hatósági vizsgadíj'],
          default: 'normál',
        }
      - { name: name, label: Név, widget: string }
      - { name: price, label: Ár, widget: number }
  - name: documents
    label: Jogi Dokumentumok
    folder: content/documents
    create: true
    fields:
      - { name: title, label: Név, widget: string }
      - label: 'Manual PDF'
        name: 'manual_pdf'
        widget: 'file'
        default: '/assets/general-manual.pdf'
        media_library:
          config:
            multiple: true

I have assets folder in my root folder and have the static/assets media folder. I tried it in macos mojave and in linux mint tessa. I do not use Cloudinary/Netlify Large Media/Uploadcare, is it required or is there a default storage for this?

bekahmcdonald commented 5 years ago

I just figured what the issue is. In my case the media folder did not exist, as I did not add any images. After adding a single image to the media folder and pushing to the repo, it all works as expected.

This worked for me too.

erquhart commented 5 years ago

I see you're using Git Gateway, where is your repo hosted?

arminnaimi commented 5 years ago

Mine is hosted on GitLab.

erquhart commented 5 years ago

We should be creating a new folder if the it doesn't exist, sounds like that isn't happening in the Bitbucket backend.

davidlower8 commented 5 years ago

Hi everyone.

I am having trouble uploading and registering images with netlify CMS. It would be great to know what the progress of this issue is and if there is a solution to fix the problem. I simply get 'no assets found'. I don't even get empty thumbnails.

I am not sure if you need the entire yml file but here it is.

backend:
  name: github
  repo: of-the-spirit/philip-website # Path to your GitHub repository

media_folder: "img/uploads"

collections:
  - name: "home-page"
    label: "Home page"
    files:
    - label: "Introduction area"
      name: "site"
      file: "_data/home.yml"
      fields:
        - label: "Title"
          name: "title"
          widget: "string"
        - label: "Subtitle"
          name: "subtitle"
          widget: "text"
  - name: "sidebar"
    label: "Sidebar"
    files:
    - label: "About section"
      name: "site"
      file: "_data/about.yml"
      fields:
        - label: "Portrait picture"
          name: "about-img"
          widget: "image"
        - label: "About info"
          name: "about-info"
          widget: "markdown"
  - name: "footer"
    label: "Footer"
    files:
    - label: "Introduction area"
      name: "site"
      file: "_data/footer.yml"
      fields:
        - label: "Title"
          name: "title"
          widget: "string"
        - label: "Subtitle"
          name: "subtitle"
          widget: "text"
  - name: "blog-posts"
    label: "Blog posts"
    folder: "_posts"
    create: true
    slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
    fields:
      - label: "Layout"
        name: "layout"
        widget: "hidden"
        default: "default-layout"
      - label: "Featured image"
        name: "img"
        widget: "image"
      - label: "Image alt tag (image description)"
        name: "img-alt"
        widget: "string"
      - label: "Title"
        name: "title"
        widget: "string"
      - label: "Excerpt"
        name: "meta"
        widget: "text"
      - label: "Body"
        name: "body"
        widget: "markdown"

If it also helps. I use gulp to take my src img folder to my _site folder. My uploads folder is inside of the img folder. I use Jekyll.

Screenshot 2019-08-01 at 23 23 46
talves commented 5 years ago

@davidlower8 have you tried to upload an image yet?

davidlower8 commented 5 years ago

@davidlower8 have you tried to upload an image yet?

@talves Yes I just did. It worked successfully actually. However it doesn't register the images currently in the folder. Is that default dehaviour? I was trying to upload via local environment which wasn't working - but it is working on live environment.

talves commented 5 years ago

They will not save locally because they are going to your repository. They have to be pulled down to your local system to show up when working local.

davidlower8 commented 5 years ago

@talves yes that makes complete sense. So the folder being empty is normal behaviour when first starting? Do I have to upload all the images manually via the CMS?

talves commented 5 years ago

You can upload them any way you like really. As a developer, just add them locally and push them all at once. 😁

davidlower8 commented 5 years ago

That is what I have done. I have at least 20 images locally which I have pushed to github and are showing on github. But they are not showing on the CMS! On 2 Aug 2019, 00:10 +0100, Tony Alves notifications@github.com, wrote:

You can upload them any way you like really. As a developer, just add them locally and push them all at once. 😁 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

talves commented 5 years ago

@davidlower8 Based on your jekyll paths I bet your path should be at media_folder: "_site/img/uploads" . It should be from the root of the repository.

davidlower8 commented 5 years ago

You were right. I had to put _site at the root. Thanks for that. On 2 Aug 2019, 00:33 +0100, Tony Alves notifications@github.com, wrote:

@davidlower8 Based on your jekyll paths I bet your path should be at media_folder: "_site/img/uploads" . It should be from the root of the repository. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

AbdifatahZamiir commented 4 years ago

s there any one who can help me to structure media_folder and public_folder media_folder: static/images public_folder: /images after posting new blog the path of the image begins / and will be image: /images/cold-conifer-dawn-917494.jpg but my previous image path was like this ../../images/AfMiI.jpg and the error will be Field "image" must not have a selection since type "String" has no subfields because there is no any data inside this field.