当前位置:网站首页>Logic of image uploading
Logic of image uploading
2022-07-19 05:04:00 【du fei】
import os
from django.conf import settings
# Upload logog picture
class UploadView(APIView):
def post(self, request):
# Get front-end data
file = request.data.get('file')
print(' Response to the request :',file.name)
# Splicing path
static_path = 'static/images/logos/'
file_path = os.path.join(settings.BASE_DIR, static_path)
# The final file name
file_name = os.path.join(file_path, file.name)
print(' Response of pictures :', file_name)
with open(file_name, 'wb') as f:
f.write(file.file.read())
# Return response
return Response({
'code': 200, 'msg': ' Image upload succeeded ', 'static_path': static_path})
边栏推荐
猜你喜欢

Penetration test 10 - scan web directories (dirb, wfuzz, wpscan, Nikto)

3.RestClient查询文档

String字符串根据符号进行特殊截取处理

CVE-2021-44228 Log4j 复现及原理

Load balancer ribbon practice

Database learning notes (I) retrieval data

机器学习之PCA特征降维+案例实践

上传七牛云的方法

Topicexchange switch is simple to use.

MySQL fuzzy matching 1, 11111 similar string problems
随机推荐
CVE-2019-14234 Django JSONField SQL注入漏洞
Embrace declarative UI
junit4和junit5区别
事务的使用-django、 SQL工具
ModelArts第二次培训笔记
图片上传的逻辑
Simple use of directexchange switches.
微服务高并发服务治理
CVE-2017-12635 Couchdb 垂直权限绕过漏洞复现
Attendance check-in and leave system based on SSM framework
SMS verification test without signature template audit
RestAPI
3.RestClient查询文档
PyGame installation -requirement already satisfied
负载均衡添加ssl证书
浅聊链路追踪
脱敏字段举例
TopicExchange交换机简单使用。
异步数据-短信验证码
Tidb performance optimization overview