Shareabout-api: Attachment (image) links broken in place detail

28 views
Skip to first unread message

Jeff Hamm

unread,
Apr 15, 2014, 8:48:06 PM4/15/14
to shareab...@googlegroups.com
With fresh local install of Shareabouts API and Shareabout Client, using development server. (local flavor of 'config.yml' is same as the default, except for the base layer definition)

Everything seems to function properly out of the box (awesome!) except:
  • When adding a Place, an image can be uploaded successfully. The (resized) image will be shown on the Place detail for the remainder of the current session, but after leaving the page and returning, theses images are not retrieved. No errors are reported, and details of the Place are otherwise complete. The image path is added to the database table and is uploaded to the filesystem (i.e. at src/attachments), but doesn't get retrieved with the rest of the Place details in the Shareabout client.

From the shareaboouts log: 
    [15/Apr/2014 20:07:13] "GET /place/attachments/ObXmtuu-blob HTTP/1.1" 200 47377 

From the shareabouts-api log:
[16/Apr/2014 00:39:39] "GET /api/v2/dawson/datasets/tagish/places/14/comments HTTP/1.1" 200 85
[16/Apr/2014 00:39:39] "GET /api/v2/dawson/datasets/tagish/places/14/support HTTP/1.1" 200 85 

In project/local_settings.py (for shareabouts-api)

MEDIA_ROOT = ' '
MEDIA_URL=' '

Are there changes required to configurations for permissions? There aren't any authorizations for uploads (the default?).

Thanks in advance.

Mjumbe Poe

unread,
Apr 17, 2014, 11:54:40 AM4/17/14
to shareab...@googlegroups.com
Hey Jeff,

There are two issues here:
  1. You have to save your attachments somewhere that the API web server has access to them, (which is what MEDIA_ROOT is for, and should probably be set to an absolute path on your file system when using the default storage) and
  2. You have to tell the server how to build an absolute URL to these files (which is what the MEDIA_URL is for). Since MEDIA_URL is blank, all your attachments are assumed to be relative urls -- i.e., if you looked at the contents of /api/v2/dawson/datasets/tagish/places/14, you'll have an attachment whose URL is "attachments/ObXmtuu-blob". On our hosted API servers, we use S3 through django-storages for this. If you want to use the local file system you might want to point the MEDIA_ROOT at one of your static folders (e.g. ".../src/project/static") and set your MEDIA_URL to something like "http://localhost:8000/static", depending on what port you're running the server on. That may work.
Hope that's helpful.

- Mjumbe


--
-- --
Shareabouts Developers group.
Unsubscribe: https://groups.google.com/d/forum/shareabouts-dev?hl=en
---
You received this message because you are subscribed to the Google Groups "Shareabouts Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shareabouts-d...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jeff Hamm

unread,
Apr 17, 2014, 6:18:49 PM4/17/14
to shareab...@googlegroups.com
Thank you very much Mjumbe. 
I suspected my trouble lay in the MEDIA_* settings.

I reconfigured MEDIA_ROOT to a subdir under the static directory, and now all the magic is happening!

Jeff
Reply all
Reply to author
Forward
0 new messages