Upload images to the cloud


I’m building a custom dashboard with customs insights and other functions. So for this I need to extract the images locally, upload it to AWS S3 an then delete it from the agent PC. The problem came when I try to delete the key from the database because the code give me no error but dont delete the image from the db. Can someone please help me with that.

import lmdb
import boto3
import os

s3 = boto3.resource('s3')

lmdb_env = lmdb.open('1541004458234.mdb',subdir=False)
lmdb_txn = lmdb_env.begin(write=True)
lmdb_cursor = lmdb_txn.cursor()

for key, value in lmdb_cursor:
    print("Key: %s, Size: %d" % (key, len(value)))
    key = str(key).replace("b'", '').replace("'", '')
    filename = 'UPLOAD/' + str(key) + '.jpg'
    with open(filename, 'wb') as of:
    s3.meta.client.upload_file(filename, 'my-bucket', 'my-key')


The OpenALPR Rolling database is where the images are stored. We chunk them into 500MB blocks and save the raw JPEG data into those blocks. They’re indexed by timestamp, so the software will automatically delete the oldest images once it reaches the disk quota. For example, if your disk quota is 10GB and we need to add an image when the database is already at 10GB, it will delete the oldest images.

It deletes the oldest images by just deleting the whole LMDB file. That is very efficient compared to individual image deletion.

In case it’s helpful, we have open sourced the source code for this module here: