An open API service indexing awesome lists of open source software.

https://github.com/tuomas2/cached_file_converter

Django app: cached file converter
https://github.com/tuomas2/cached_file_converter

Last synced: 6 days ago
JSON representation

Django app: cached file converter

Awesome Lists containing this project

README

          

=====
Simple cached file converter service (Django 2.0 app)
=====

1. Check MD5 sum of a file on client side to avoid waste of bandwith
2. Is file cached on server?
1. Yes
1. If file is cached, get immediately a download link for cached converted file
2. No
1. Upload file for conversion
2. Convert file on server (separate task processor)
3. Get a link for user to download converted file

Quick start
-----------

1. Add "cached_file_converter" to your INSTALLED_APPS setting like this::

INSTALLED_APPS = (
...
'cached_file_converter',
)

and set up some settings:

# the directory where original files will be uploaded
ORIGINAL_FILES = os.path.join(BASE_DIR, 'original')
# the directory where converted files will be cached
CONVERTED_FILES = os.path.join(BASE_DIR, 'converted')
# increase this if you want all your files converted again
CONVERTER_REVISION = 0
# set up / import your converter function here.
def convert(input_file, output_files_and_options, task):
# output_files_and_options is a dict of form {'Option set 1': filename, options}
for file, options in output_files_and_options.values():
do_some_conversion(file, options)

CONVERTER_FUNC = convert

# Define options for differnet conversions that take place
CONVERTER_OPTIONS = {'Option set 1': dict(), 'Option set 2': dict(option2=True)}

# what do you want visible converted filename to be to the end user
def get_download_filename(orig_filename):
return orig_filename.rsplit('.', 1)[0] + '.zip'

GET_DOWNLOAD_FILENAME = get_download_filename

2. Include the polls URLconf in your project urls.py like this:

url(r'^cached_file_converter/', include('cached_file_converter.urls')),

3. Run `python manage.py migrate` to create the polls models.

4. Start development server
python manage.py runserver

and start task prosessor

python manage.py process_tasks

and visit http://127.0.0.1:8000/cached_file_converter/.