Example #1
0
def UploadPic(request):
    """upload pic to qiniu."""
    if request.method == 'POST':
        img = request.FILES.get('Filedata', None)
        type = request.POST.get('type', None)
        if type:
            qn = SuperQiniu(img, w=800, h=520)
        else:
            qn = SuperQiniu(img)
        qn.uploadFile()
        remote_url = qn.downloadFile()
        key = qn.getKey()
        pic = Pic.objects.create(img=remote_url, key=key)
        return ajax.ajax_ok({'id':pic.id, 'url':pic.img, 'key':key})
Example #2
0
def UploadPic(request):
    """upload pic to qiniu."""
    if request.method == 'POST':
        img = request.FILES.get('Filedata', None)
        type = request.POST.get('type', None)
        if type:
            qn = SuperQiniu(img, w=800, h=520)
        else:
            qn = SuperQiniu(img)
        qn.uploadFile()
        remote_url = qn.downloadFile()
        key = qn.getKey()
        pic = Pic.objects.create(img=remote_url, key=key)
        return ajax.ajax_ok({'id': pic.id, 'url': pic.img, 'key': key})