예제 #1
0
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'])
예제 #2
0
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'])
예제 #3
0
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'])
예제 #4
0
 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
예제 #5
0
 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
예제 #6
0
def __merge():
    upload_type = request.form.get('file_type', None)
    upload = Upload(upload_type=upload_type)
    upload.merge()
    return upload.info()
예제 #7
0
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