Skip to content

A flask server with AWS s3 setup to provide certain features. This is the backend for the SmallFiles app.

Notifications You must be signed in to change notification settings

Anonymous961/pdf_compressor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PDF compressor Flask server

This is the backend of PDFLite, which primarily offers three main features.

  1. Compress PDF

    1. This feature uses ghostscript.
    2. There are quality such as screen, ebook, printer, prepress.
  2. Convert PDF to DOC

  3. Compress img

    1. Accepts any image type

    2. There are quality range from 0 to 100.

      • Best quality is between 20 to 80

Setup local development evironment

Prerequisites

  1. python3
  2. ghostscript
  3. AWS account with S3 bucket

Setup virtual environment

$ mkdir myproject
$ cd myproject
$ python3 -m venv .venv
  • To activate virtual environment
$ . .venv/bin/activate
  • install dependencies
$ pip install -r requirement.txt

Create .env file

# in .env file

AWS_BUCKET_NAME=your_bucket_name
AWS_ACCESS_KEY=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_access_key
AWS_DOMAIN=http://your_bucket_name.s3.amazonaws.com/
  • To run flask server
$ flask --debug run

Setup S3 bucket for public access

Bucket policy should look like this

{
    "Version": "2012-10-17",
    "Id": "IDxyz",
    "Statement": [
        {
            "Sid": "Stmt731289371238",
            "Effect": "Allow",
            "Principal": "*",
            "Action": "s3:GetObject",
            "Resource": "arn:aws:s3:::<bucketname>/<key>"
        }
    ]
}
  • You can get policy examples from here
  • Or you can generate policy from here
  • NOTE: untick block public access.

File access

  • Files uploaded to a S3 bucket can be accessed via a public URL that usually looks like this:
https://nextagram-backend.s3.amazonaws.com/nextagram.jpg
https://<bucket_name>.s3.amazonaws.com/<filename>.<extension>

About

A flask server with AWS s3 setup to provide certain features. This is the backend for the SmallFiles app.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages