参考:https://blog.csdn.net/zahuopuboss/article/details/54891917
参考:https://blog.csdn.net/zzg_550413470/article/details/51538814
参考:https://www.cnblogs.com/linxiyue/p/7442232.html
django 文件存储:https://docs.djangoproject.com/en/dev/ref/files/storage/
django 视图接收:https://docs.djangoproject.com/en/dev/ref/files/uploads/#django.core.files.uploadedfile.UploadedFile
示例代码:
def upload_view(request): file_object = request.FILES.get('f','') print 'file name:', file_object.name, 'file size:', file_object.size, 'file content_type:', file_object.content_type if file_object: storage_system_object = get_storage_class()(settings.BASE_DIR + '/filestorage/') upload_file_object = ContentFile(content = file_object.read(), name = file_object.name) storage_system_object.save(name = file_object.name, content = upload_file_object) return HttpResponse(json.dumps({'status':200, 'info':""}))
上传:
# curl -F form
curl http://projecturl/path/ -F "f=@uploadfile"