def test_generation_of_unique_name():
        n1 = generate_name('foo.jpg')
        n2 = generate_name('foo.jpg')
        regexp = re.compile(r'^uploads\/[0-9a-f-]{36}\/foo\.jpg$')

        assert n1 != n2
        assert regexp.search(n1)
示例#2
0
def handle_upload():
    if 'uploaded_file' not in request.files:
        flash('No file part')
        return redirect(request.url)

    uploaded_file = request.files['uploaded_file']
    destination_name = generate_name(uploaded_file.filename)
    media_storage.store(dest=destination_name, source=uploaded_file)

    photos_list.append(destination_name)

    return prepare()