KML Upload unsuccessful

Getting the same error:

“The file could not be uploaded.”

when I try to upload a KML file to my hosted Farmos instance. Any pointers?

1 Like

It sounds like you are getting this error before hitting “parse” so it might be an issue with all file uploads. Could you try uploading a file to a log or asset to make sure this is not isolated to the KML importer?

If you are hosting the server yourself you need to configure the private file system in Drupal: Installing farmOS | farmOS

The Drupal core file module has some instructions on this too: File module overview | File module | Drupal Wiki guide on Drupal.org

1 Like

I did add the line to the settings.php file as suggested (this is a docker install)
Yes - it is an issue with all file uploads, not KML.
Tried uploading to a log, still didn’t work.

Any other suggestions?

1 Like

Maybe the docker user of the container can’t access the directory that you are pointing on that settings.php. Try to chmod 777 that directory and try again. If it works, you know it’s a permissions problem

2 Likes

I did add the line to the settings.php file as suggested (this is a docker install)

Great that was going to be my first question. :slight_smile:

Also curious: did you use the docker-compose.development.yml or docker-compose.production.yml template? Or did you set up volume mounts in a different way?

No - I just followed the install instructions

docker pull farmos/farmos:2.x.y
docker run --rm -p 80:80 -v "${PWD}/sites:/opt/drupal/web/sites" farmos/farmos:2.x.y
Was I supposed to use the docker-compose-development.yml 

The directory didn’t even exist even though I added it to the settings file. I feel I am doing something wrong on the install even though I am literally following the install guide on the website (or trying to).
I created the directory and gave it 777. Still nothing, though. Cannot upload any file

Here is another sign I am doing something wrong: Just noticed that when I do “docker run…” I get:
“farmOS sites directory not detected. Copying from pre-built files in the Docker image.”

Was I supposed to use the docker-compose-development.yml

Nope - you’re doing it right!

The directory didn’t even exist even though I added it to the settings file.

I’m pretty sure Drupal will automatically generate the directory, if it is able to. But creating it manually doesn’t hurt either.

I created the directory and gave it 777. Still nothing, though. Cannot upload any file

Huh. That is odd. The /opt/drupal/web/sites/default/private/files directory just needs to be writable by www-data user (the www-data user inside the container, specifically - which is usually the same as outside on a standard Linux install, but worth double-checking perhaps). Either way 0777 should work.

Just to be sure, is this the line you added to your sites/default/settings.php file?

$settings['file_private_path'] = '/opt/drupal/web/sites/default/private/files';

This is normal. The farmOS Docker image has a custom entrypoint script that will run when the container is first started. It checks to see if the sites directory is empty (which is what happens when you bind-mount it as a Docker volume), and if so then it copies the necessary scaffolding files into it. This happens here: https://github.com/farmOS/farmOS/blob/3cebccc2d19a6874d3194bad1b9eadad2faf7262/docker/docker-entrypoint.sh#L19

If you stop your container and re-run the same docker run command, with the same volume mount, then you won’t see that message the second time (you shouldn’t anyway), because the bind-mounted sites directory has the necessary files in it (it’s no longer empty).

One other tip to try to debug this: with the container running, open a bash session inside the container with the following (find your [container-id] with docker ps first):

docker exec -it [container-id] bash

Then you can check that the directory exists and has the proper permissions from the Docker container’s perspective:

cd /opt/drupal/web/sites/default/private/files
ls -al

If you can paste the output of that ls -al here I can tell you if it looks good or not.

Shows that the directory doesn’t exist

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
290034ac2f5b farmos/farmos “docker-entrypoint.s…” 3 minutes ago Up 3 minutes 0.0.0.0:80->80/tcp, :::80->80/tcp boring_noyce
root@agralogics-s-2vcpu-2gb-sfo3-01:~# docker exec -it 290034ac2f5b bash

root@290034ac2f5b:/opt/drupal# cd /opt/drupal/web/sites/default/private/files
bash: cd: /opt/drupal/web/sites/default/private/files: No such file or directory

when I get out of the bash, it can see it
root@290034ac2f5b:/opt/drupal# exit
exit
root@agralogics-s-2vcpu-2gb-sfo3-01:~# cd /opt/drupal/web/sites/default/private/files
root@agralogics-s-2vcpu-2gb-sfo3-01:/opt/drupal/web/sites/default/private/files#

Also, this time when I started docker - it DIDN’T say that it can’t find the file

root@agralogics-s-2vcpu-2gb-sfo3-01:~/farmos# docker run --rm -p 80:80 -v “${PWD}/sites:/opt/drupal/web/sites” farmos/farmos
Attempting: apache2-foreground
[Tue Apr 12 21:26:46.307432 2022] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.51 (Debian) configured – resuming normal operations
[Tue Apr 12 21:26:46.307500 2022] [core:notice] [pid 1] AH00094: Command line: ‘apache2 -D FOREGROUND’

1 Like

You have to think that a docker container (whatever runs inside docker) is like a computer out of your network. In this case looks like you have created the upload directory in your computer and not in the container. The docker container can’t access to the “/opt/drupal/web/sites/default/private/files” in the “agralogics-s-2vcpu-2gb-sfo3-01” computer, it doesn’t know that such thing exists.

Try with

docker exec ContainerID mkdir -p -m 777 /opt/drupal/web/sites/default/private/files

I usually start with docker-compose, much easier. It creates a www folder where you can access with a file explorer, create the folder, give it permissions… Maybe you should try the easy way first and go to custom docker management when you have a little more practice with it.

1 Like

Ah ok yea! @c4ndel4 is right this is not the same directory as the one you are bind-mounting into the Docker container as a volume… so even though it exists it is not being used…

Based on the docker run command you are using, you should have the directory you need in the same directory that you ran the command from:

root@agralogics-s-2vcpu-2gb-sfo3-01:~/farmos# docker run --rm -p 80:80 -v “${PWD}/sites:/opt/drupal/web/sites” farmos/farmos

The -v “${PWD}/sites:/opt/drupal/web/sites” part means “create a directory called sites in this current directory, and bind-mount it into the container as /opt/drupal/web/sites”.

So that’s where the private file directory will need to be, and sites/default/settings.php is where you’ll add the line pointing to it.

Hope that helps!!

Oh one other minor tip:

docker run --rm -p 80:80 -v “${PWD}/sites:/opt/drupal/web/sites” farmos/farmos

We recommend using a specific version of the Docker image, so that you don’t accidentally upgrade it without knowing in the future. farmos/farmos translates to farmos/farmos:latest, which will always be the most recent tagged release (currently farmos/farmos:2.0.0-beta3.

It would be better to run farmos/farmos:2.0.0-beta3 explicitly, so that you can intentionally upgrade when new versions come out, and remember to run update.php at that time (this handles any necessary database updates that might be required between versions). More info here: Updating farmOS | farmOS

The documentation is (always) a work in progress! If you find something is missing or misleading please let us know! :slight_smile:

1 Like

ok - appreciate the help. But still having issues uploading a file.

my local dir “root” is /root/farmos/
This is where I the docker from.

I have a /root/farmos/sites/default/private/files folder that I have 777 on (recursively for each level starting with /farmos

In my settings.php file, I have the following:
$settings[‘file_private_path’] = ‘/root/farmos/sites’;
(I’ve tried various combinations).

Pls do help.

Sumer
ps: I am now using farmos2.0.0 as you suggested.

1 Like

Great! Almost there I think… :slight_smile:

In my settings.php file, I have the following:
$settings[‘file_private_path’] = ‘/root/farmos/sites’;

This needs to be the path inside the container, which will be /opt/drupal/web/sites/default/private/files.

And just to be safe, I would recommend using the explicit path to the directory in your docker run command instead of ${PWD} - just because ${PWD} will vary depending on where you run the command. So something like this (based on previous comments):

docker run --rm -p 80:80 -v "/root/farmos/sites:/opt/drupal/web/sites" farmos/farmos:2.0.0-beta4

(I used 2.0.0-beta4 there because we just released it today! :tada: :smile:)

That should work from anywhere - and will always bind-mount the same /root/farmos/sites directory to /opt/drupal/web/sites inside the container, regardless of where you run the command from.

Let us know if that works! :crossed_fingers:

That worked! Thanks so much for all your help and handholding!

Q:

  1. How to add the Mapbox satellite layer
  2. How do I see the custom module development toolkit. Is there a link you can point me to?

Many thanks! The journey begins!

Sumer

2 Likes

:tada: :tada: :tada:

  1. How to add the Mapbox satellite layer

There are a few steps to this:

  1. Create a Mapbox account and get an API key: Sign up | Mapbox
  2. Enable the “farmOS Mapbox” module in /admin/modules (this is the FULL list of Drupal modules - not all are “supported” in farmOS so use with care)
  3. Go to /farm/settings/map and enter your API key.

The Mapbox layers should appear in the map layer options.

  1. How do I see the custom module development toolkit. Is there a link you can point me to?

We have some documentation for getting started with module development here: farmOS module development | farmOS

That’s a bit of a rabbit hole in itself (since Drupal module development itself is a rabbit hole, and farmOS is a layer on top of that) - but feel free to ask questions as they come up! Happy to point you in the right direction. :slight_smile:

Cool. Thanks!
Very helpful. :smiley:

2 Likes