images.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:network-api 作者: mozilla 项目源码 文件源码
def get_image_upload_path(
    app_name,
    prop_name,
    instance,
    current_filename,
    suffix=''
):
    timestamp = int((
        datetime.now(tz=timezone.utc) -
        datetime(1970, 1, 1, tzinfo=timezone.utc)
    ).total_seconds())

    filename = '{name}{suffix}_{timestamp}{ext}'.format(
        name=slugify(getattr(instance, prop_name), max_length=300),
        suffix=suffix,
        timestamp=str(timestamp),
        ext=os.path.splitext(current_filename)[1],
    )

    return 'images/{app_name}/{filename}'.format(
        app_name=app_name,
        filename=filename,
    )
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号