File Upload Path for URL

Background
Cloudcannon provides a nifty URL field that allows content editors to upload and link to a file. However, there do not appear to be any settings for the URL field that allow developers to set the destination for file uploads. This creates the potential for content editors to add files to the root of the site. The alternative is training content editors on the file structure of the site and hoping they will follow directions which is not recommended.

Requirements
As a developer, I would like to be able to set the upload path as I would in the images field in order to guarantee

As a content editor, I would like to select the Link to File option and upload a file to the intended directory without having to find it.

Acceptance Criteria

  1. Select the three dots next to the URL input
  2. Select Link to a File
  3. The designated upload directory should pop up in a module (eg assets/files/)
2 Likes

Hey Ed, I just tried it out and it looks like

  file_input:
    type: file
    options:
      paths:
        uploads: uploads/files

works for me to direct the user to the specified uploads/files folder.

Happy to help dig deeper if that’s not working on your end!

1 Like

Where would I add that within the configuration cascade? I added this to the _inputs in my cloudcannon.config.yml and I added cascade true to make sure it trickled down to my URL fields, eg: cta.button.url

_inputs:
  file_input: 
    cascade: true
    type: file
    options: 
      paths:
        uploads: assets/files

This does not pass the acceptance criteria. When I select the file option, the root directory pops up by default. My directory contains the assets/files directory. The correct directory will pop up for my images uploads where I have the following setting:

image_path:
    type: image
    cascade: true
    options:
      paths:
        uploads: assets/images/uploads
1 Like

Hey Ed,

Re reading your question I see it was about URL inputs rather than file inputs so this isn’t exactly what you want (I’m guessing that you want the cta.button.url to be able to have standard links as well as files?)

If a straight file input does work, then what you’ve done is 90% of the way there, it just needs to be the name of your input (rather than my default example of ‘file_input’) - for example:

_inputs:
  cta.button.url: 
    cascade: true
    type: file
    options: 
      paths:
        uploads: assets/files

The issue is that CloudCannon’s URL field supports File uploads, but there is no way to set the upload path. Your solution will just turn the URL field into a file upload field which isn’t what I’m trying to achieve per the acceptance criteria.
If a select File:

I should then have the ability to determine the upload path, but only the root will appear:

URL input does not list paths as a option so I cannot add it there.

1 Like

Yeah, I totally get where you’re coming from. I had a quick chat with the application team, and it’s definitely on their radar, but there’s no confirmed timeline for it just yet.

In the meantime, a possible workaround could be setting up a structure where the user can add either a URL or a file, each configured accordingly. If that sounds helpful, I’m happy to send through an example of how to set that up :slightly_smiling_face:

1 Like