def delete_remote_storage(sender, instance, **kwargs):
    """Delete media files from remote storage.

    Iterate through all associated remotely stored media and
    trigger a delete. This is handled through a signal so it
    is fired even when performing bulk deletes.

    Signal: pre_delete
    Sender: Media
    """
    from .tasks import delete_media
    for storage in instance.remotestorage_set.all():
        delete_media.delay(storage.id)
