Ejemplo n.º 1
0
 def upyun_mkdir(self,request, *args, **kwargs):
     new_dir = request.DATA['new_dir']
     auth_para = request.DATA
     print new_dir
     up = Upyun_Api(auth_para["space"], auth_para["username"], auth_para["password"])
     up.mkdir(new_dir)
     return Response({'result': new_dir + ' has been created'})
Ejemplo n.º 2
0
 def upyun_delete(self, request, pk=None):
     up_file = request.DATA['file_name']
     auth_para = request.DATA
     print up_file
     up = Upyun_Api(auth_para["space"], auth_para["username"], auth_para["password"])
     up.delete(up_file)
     return Response({'result': up_file + ' has been deleted'})
Ejemplo n.º 3
0
 def upyun_upload(self, request, pk=None):
     auth_para = request.DATA
     print auth_para
     up = Upyun_Api(auth_para["space"], auth_para["username"], auth_para["password"])
     filename = request.FILES['file']
     filenames = str(filename)
     print filenames
     up.put(auth_para["dir"] + '/' + filenames, filename)
     return Response({'result': filenames + 'upload'})
Ejemplo n.º 4
0
 def upyun_get_info(self, request, pk=None):
     auth_para = request.DATA
     print auth_para
     data_all = {}
     while True:
         try:
             up = Upyun_Api(auth_para["space"], auth_para["username"], auth_para["password"])
             data_all["dir"] = up.getlist(auth_para["dir"])
             usage = up.usage()
             print up
             break
         except:
             pass
     usage_mea = str(usage) + 'B'
     for mea in ['KB', 'MB', 'GB']:
         usage, usage_mea = self.divide_math(usage, usage_mea, mea)
     data_all["usage"] = usage
     data_all["usage_mea"] = usage_mea
     for i in data_all["dir"]:
         i["time_style"] = self.time_exchange(float(i["time"]))
     return Response(data_all)