Micropub/photo issues

I realize this may not be something directly related to Kirby, but I thought maybe someone might be able to point me in the right direction.

I have micropub generally set up, but I’m getting an error that seems to be related to photos. All of my tests so far are successfully posting to my blog. If I go into the panel, the attached image file is there under Files. But the cover image field isn’t populated, and the photo doesn’t show up anywhere. In addition to that, the micropub client gets an error “Your endpoint did not return a Location header.”

I’m a bit lost here. Is there something I need to do in the code on Kirby to fix the location header issue? Is it simply not possible with the default blog in the StarterKit?

Upon further inspection, the new test posts are coming in under owner pi and group pi (instead of www-data) - that seems to be the cause of the issue.

How do I force Kirby to use pi:www-data as default?

This can’t be done through Kirby, this is a server thing.

I think you have two options:

  1. create a cron job that changes ownership/permissions
  2. a combination of set-gid and default acls

(maybe there are other options, I have little server experience)

I ended up using a slightly different solution - main difference being that it was easier for me to comprehend :slight_smile:


So we made progress. The directory and file (article.txt) have pi:www-data set correctly. The image, however, is still pi:pi - so I guess it is something to do with file uploading. I think I saw a few messages about that while I was searching the forums earlier. I’ll keep looking…

I’m suspecting the offending code is somewhere in this section of the micropub plugin, although I’m unsure…

// Handle the Media-endpoint files
foreach ($data as $key => $field) {
  if (str::startsWith($field, $endpoint->mediaUrl)) {
    $filename = f::filename($field);
    $newfilename = substr($filename, 41); // Without the sha1-hash and dash
    f::move($endpoint->mediaPath . DS . $filename,
            $newEntry->root() . DS . $newfilename);
    $update[$key] = $newfilename;