<commit_before>#!/usr/bin/env python3

import boto
import config
import hashlib
from boto.s3.key import Key
from flask import Flask, abort, jsonify, request, send_file
from wand.image import Color, Image

app = Flask(__name__)
app.config.from_object(config)


def upload(image):
    s3 = boto.connect_s3()
    bucket = s3.get_bucket(app.config['AWS_BUCKET_NAME'])
    blob = image.make_blob()

    h = hashlib.md5()

    # generate filename from 32 random letters
    # filename = ''.join(random.sample(string.ascii_letters, 32))

    # generate filename from image md5
    h.update(blob)
    filename = h.hexdigest()

    key = Key(bucket)

    # key key is image filename, data is blob and headers<commit_msg>Revert to random name instead of keep file name<commit_after>#!/usr/bin/env python3

import boto
import config
import hashlib
import random
import string
from boto.s3.key import Key
from flask import Flask, abort, jsonify, request, send_file
from wand.image import Color, Image

app = Flask(__name__)
app.config.from_object(config)


def upload(image):
    s3 = boto.connect_s3()
    bucket = s3.get_bucket(app.config['AWS_BUCKET_NAME'])
    blob = image.make_blob()

    # generate filename from 8 random letters
    filename = ''.join(random.sample(string.ascii_letters, 8))

    # generate filename from image md5
    # h = hashlib.md5()
    # h.update(blob)
    # filename = h.hexdigest()

    key = Key(bucket)

    # key key is image filename, data is blob and headers
{'fraction_non_alphanumeric': 0.09966329966329966, 'fraction_numerical': 0.013468013468013467, 'mean_word_length': 3.7628205128205128, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7157612', 'n_tokens_mistral': 500, 'n_tokens_neox': 474, 'n_words': 145}