def upload_attach(): upload_type = request.form.get('file_type', 'attach') upload = Upload(upload_type=upload_type) upload.upload() info = upload.info() if info['state'] == "SUCCESS": return Success(data=info) else: return Fail(message=info['state'])
def upload_avatar(): upload_type = request.form.get('file_type', 'images') upload = Upload(upload_type=upload_type) upload.upload() info = upload.info() if info['state'] == "SUCCESS": # if upload_type == 'images': # Images(old_file_name=info['filename']).clip(dst_w=100, dst_h=100).thumb(width=250, height=250).save() return Success(data=info) else: return Fail(message=info['state'])
def upload_thumb(): upload_type = request.form.get('file_type', 'images') upload = Upload(upload_type=upload_type) upload.upload() info = upload.info() if info['state'] == "SUCCESS": if upload_type == 'images': Images(old_file_name=info['filename']).thumb(width=640, height=480).save() return Success(data=info) else: return Fail(message=info['state'])
def __uploadfile(self): upload = Upload(upload_type="attach", file_field='upfile') upload.upload() info = upload.info() if info['state'] == "SUCCESS": self.__result = upload.info() else: self.__result = info
def __uploadimage(self): upload = Upload(upload_type="images", file_field='upfile') upload.upload() info = upload.info() if info['state'] == "SUCCESS": try: img = Images(old_file_name=info['filename']).thumb(width=int(self.__system['images_max_width'])) if int(self.__system['document_water']) == 1: img = img.water() img.save() self.__result = upload.info() except Exception as e: self.__result = {'state': '图片压缩失败!'} else: self.__result = info
def __merge(): upload_type = request.form.get('file_type', None) upload = Upload(upload_type=upload_type) upload.merge() return upload.info()
def __chunk_upload(): upload_type = request.form.get('file_type', None) upload = Upload(upload_type=upload_type) upload.chunk_upload() info = upload.info() return info