RESTful External Archive Server for archiving data uploaded by the Field Observation Server
Andrew Smolik, multipart-form-data_django_rest_framework_tutorial, (2012), GitHub repository, https://github.com/ansother/multipart-form-data_django_rest_framework_tutorial
This files provides commands to upload files to the django-rest-framework api.
-
Open a python interpreter:
$ python
-
Import requests in python interpreter:
$import requests
-
Swap out the YOUR_URL in the url variables with your root url:
$url_upload_form = 'YOUR_URL/api/upload_form/'
$url_upload_serializers = 'YOUR_URL/api/upload_serializers/'
-
Paste url variables into python interpreter:
-
Create a file to upload:
$files = {'docfile': ('report.csv', 'some,data,to,send\nanother,row,to,send\n')}
-
Upload a file with a form:
$r=requests.post(url_upload_form, data={'title':'file_upload_form'}, files=files)
-
Upload a file with django-rest-framework serializer:
$r=requests.post(url_upload_serializers, data={'title':'file_upload_serializers'}, files=files)
-
To view uploaded data in the django-rest-framework view go to:
$YOUR_URL/api/upload_form/
or
$YOUR_URL/api/upload_serializers/
This files provides commands to upload images to the django-rest-framework api.
-
Open a python interpreter:
$ python
-
Import requests in python interpreter:
$import requests
-
Swap out the YOUR_URL in the url variables with your root url:
$url_upload_form = 'YOUR_URL/api/upload_form_images/'
$url_upload_serializers = 'YOUR_URL/api/upload_serializers_images/'
-
Paste url variables into python interpreter:
-
Create an image to upload:
$images = {'image': ('image.jpg', image_data)}
-
Upload a file with a form:
$r=requests.post(url_upload_form, data={'title':'file_upload_form_images'}, files=images)
-
Upload a file with django-rest-framework serializer:
$r=requests.post(url_upload_serializers, data={'title':'file_upload_serializers_images'}, files=images)
-
To view uploaded data in the django-rest-framework view go to:
$YOUR_URL/api/upload_form_images/
or
$YOUR_URL/api/upload_serializers_images/