{% extends 'core/base.html' %} {% block content %}

公开内容

{% if user.is_authenticated %} 添加内容 {% endif %}
{% if content_by_type %} {% for type_name, contents in content_by_type.items %}
{{ type_name }}
{{ contents|length }} 项
{% for content in contents %}
{% if content.url %} {{ content.title }} {% else %} {{ content.title }} {% endif %} {% if content.is_temp_file %} 临时文件 {% endif %}
{% if content.content %}

{{ content.content|truncatechars:200 }}

{% endif %} {% if content.file %} 下载文件 {% endif %} {% if content.is_temp_file and content.expire_at %} {% load humanize %} {{ content.expire_at|naturaltime }}过期 {% endif %}
{% if user.is_authenticated %} {% endif %}
{% endfor %}
{% endfor %} {% else %}
暂无公开内容

请稍后再来查看

{% if user.is_authenticated %} 添加内容 {% endif %}
{% endif %}
{% csrf_token %}
临时文件上传 API
上传文件

端点: POST /api/v1/temp-upload/

参数
参数名 类型 必填 说明
title string 文件标题
file file 文件 (最大500MB)
expire_type string 过期时间: expire_1h (1小时) / expire_1d (1天) / expire_7d (7天)
响应示例
{
  "success": true,
  "message": "上传成功",
  "id": 1,
  "file_url": "/media/public_files/xxx.pdf",
  "file_name": "document.pdf",
  "file_size": 1048576,
  "expire_at": "2026-05-25T18:30:00Z",
  "expire_type": "expire_1d"
}
cURL 示例
curl -X POST -F "file=@document.pdf" -F "title=测试文件" -F "expire_type=expire_1d" http://localhost:8000/api/v1/temp-upload/
{% endblock %}