Colin is daily life record

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

又拍云文件上传

文件操作基础

import upyun
# 新建又拍云实例
up = upyun.UpYun('md233',username='wangrui',password='7Ly7NfX30PQ63GyPFIlSIHiQ2QRWQz76')
# 上传文件
up.put('/upyun_test.text','afsdfsdfds\n你好你好你好\n')
# 文件流操作(节省内存)
with open('./md.png','rb')as f:
# 上传操作
res = up.put('/upyun_test.png',f,checksum=True)
# 目录操作
up.mkdir('/upyun_test/')
# 移动文件
up.move('/upyun_test.png','/upyun_test/upyun_test.png')
# 复制文件
up.copy('/upyun_test.text','/upyun_test/upyun_test1.txt')
# 断点续传
with open('E:/阅卷视屏.mp4','rb') as f:
res = up.put('/upyun/test.mp4',f,checksum=True)
# 下载文件
res = up.get('/upyun_test/upyun_test.png')
# 删除文件
up.delete('/upyun_test/upyun_test.png')

又拍云项目实践

class Del(APIView):
def get(self,request):
# 接收参数
name = request.GET.get('name',None)
up = upyun.UpYun('md233',username='wangrui',password='7Ly7NfX30PQ63GyPFIlSIHiQ2QRWQz76')
up.delete(name)
return Response({'code':200,'img':'删除成功'})
class Chuangjian(APIView):
# 创建目录
def get(self,request):
uid = request.GET.get('uid')
dirname = request.GET.get('dirname')
up = upyun.UpYun('md233',username='wangrui',password='7Ly7NfX30PQ63GyPFIlSIHiQ2QRWQz76')
up.mkdir('/%s/'%dirname)
return Response({'msg': '创建成功'})
<div>
<img :src="src" >
<Avatar :src="src" :width="150" fit="fill"></Avatar>
<br />
<Button color="red" @click="del_Avatar">删除</Button>
&emsp;&emsp;
<input type="text" /><Button color="blue" @click="newdir">创建目录</Button>
</div>
//新建文件夹
newdir(){
var uid = localStorage.getItem("uid");
this.axios.get("http://127.0.0.1:8000/chuang/", {
params: { 'uid': uid,'dirname':this.dirname}
}).then(result => {
console.log(result.data)
})
},
// 删除头像操作
del_Avatar:function(){
this.axios.get("http://127.0.0.1:8000/del/",{params:{'name':this.yp_name}}).then(res=>{
console.log(res)
})
}

posted on   酷酷的瑞瑞  阅读(8)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
点击右上角即可分享
微信分享提示