def upload_avatar(request): '''头像上传''' file = request.FILES.get('avatar') if file: save_upload_file(request.user, file) return render_json(None) else: return render_json(None, error.FILE_NOT_FOUND)
def upload_avatar(request): '''头像上传''' #1,接受用户上传的头像 #2.异步将头像上传到七牛云 #3.将用户的头像的URL保存到数据库 file = request.FILES.get('avatar') if file: save_upload_file(file, request) return render_json(None) else: return render_json(None, error.FILE_NOT_FOUND)
def upload_avatar(request): '''头像上传''' # 1. 接收用户上传的头像 # 2. 定义用户头像名称 # 3. 异步将头像上传七牛 # 4. 将 URL 保存入数据库 file = request.FILES.get('avatar') if file: save_upload_file(request.user, file) return render_json(None) else: return render_json(None, error.FILE_NOT_FOUND)
def upload_avatar(request): '''头像上传''' ''' 1.get user avatar 2.rename user avatar name 3.upload avatar to qiniu 4.save url to redis ''' file = request.FILES.get('avatar') if file: save_upload_file(request.user, file) return render_json(None) else: return render_json(None, error.FILE_NOT_FOUND)
def upload_avatar(request): '''上传个人形象''' avatar = request.FILES.get('avatar') filepath, filename = save_upload_file(request.user, request.user, avatar) # 上传个人头像到七牛云 「未测试」 # upload_avatar_to_qn(filepath, filename) return render_json(None)
def upload_avatar(request): '''上传个人形象''' avatar = request.FILES.get('avatar') filepath, filename = save_upload_file(request.user, avatar) upload_avatar_to_qiniu(request.user, filepath, filename) return render_json(None)