jhubert / pydocx-s3-images

An mixin for PyDocX that uploads the images to an S3 bucket instead of returning them as Data URIs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

pydocx-s3-images

Overview

An mixin for PyDocX that uploads the images to an S3 bucket instead of returning them as Data URIs when converting from .docx to html.

Requirements

  • Python 2.7
  • Works on Linux, Windows, Mac OSX, BSD

Install

The quick way:

pip install pydocxs3upload

Usage

First of all, to use this mixin, you need to create you own amazon s3 bucket and give public permission so that uploaded images can be accessed from generated html files. Here you can find a guide how to do that. Once we have the bucket created, we need to generate a singed request that will be used to upload data to s3. So, because of this signed request you have full control over the uploaded images. Using this gist you can simple generate such signature using boto library.

Here is an example of mixin usage:

Note that you can use the same signed request to convert any docs you want. So, in order to avoid uploading images with the same name and overriding previous one, each image is appended a timestamp which makes it unique. If, for some reasons, you don't want this feature by default you can change it by passing parameter 'unique_filename': False.

In this case all images are named as image1, image2, ..., imagen.

About

An mixin for PyDocX that uploads the images to an S3 bucket instead of returning them as Data URIs

License:Apache License 2.0


Languages

Language:Python 96.4%Language:Makefile 3.6%