Ejemplo n.º 1
0
def _upload_artwork(unique_identifier, song_file):
    temp_filename = "tmp_" + str(uuid.uuid4()) + ".mp3"
    with open(temp_filename, "w+") as f:
        f.write(song_file.read())

    mutagen_file = File(temp_filename)
    if 'APIC:' not in mutagen_file.tags:
        os.remove(temp_filename)
        return ""
    artwork = mutagen_file.tags['APIC:'].data
    image_file = StringIO()
    image_file.write(artwork)
    image_file.seek(0)
    os.remove(temp_filename)

    artwork_filename = FILE_DIR + "/" + unique_identifier + ".jpg"
    boto_client = BotoClient(AWS_BUCKET_NAME)
    artwork_url = boto_client.upload(artwork_filename, image_file)
    song_file.seek(0)
    return artwork_url
Ejemplo n.º 2
0
def _upload_song(unique_identifier, song_file):
    song_filename = FILE_DIR + "/" + unique_identifier + ".mp3"
    boto_client = BotoClient(AWS_BUCKET_NAME)
    song_url = boto_client.upload(song_filename, song_file)
    song_file.seek(0)
    return song_url