django-osgeo-importer
django-osgeo-importer copied to clipboard
Importer Fails when Amazon S3 is used as the storage backend.
The file uploads successfully after making a few changes noted below but fails to import because its unable to open the file:
Request URL:http://mydomain.com/importer-api/data/152/
Response
{
"complete":true,
"date":"2016-04-03T06:39:34.878654",
"file_size":"7.6KB",
"file_type":null,
"file_url":"https://static.s3.amazonaws.com/media/uploads/Sightings.zip",
"id":152,
"layers":[
],
"metadata":"",
"name":"Sightings.zip",
"resource_uri":"/importer-api/data/152/",
"size":7798,
"state":"UPLOADED",
"upload_dir":null,
"user":"/api/profiles/1/"
}
This exception is raised and not handled gracefully by the caller.
https://github.com/ProminentEdge/django-osgeo-importer/blob/master/osgeo_importer/inspectors.py#L148
By handling the exception here: https://github.com/ProminentEdge/django-osgeo-importer/blob/master/osgeo_importer/views.py#L65
and here:
https://github.com/ProminentEdge/django-osgeo-importer/blob/master/osgeo_importer/views.py#L87
and setting a default value for description in case of exception allowed the 200 Response referenced above. As noted in the JSON response, there are values missing but the url to the uploaded file is valid. A possible solution could be for the importer to leverage the storage backend to ensure it gets a handle on the file regardless of local or remote storage configuration.
from django.core.files.storage import default_storage as storage