예제 #1
0
def AddImageByUrl(url,fileName,tag):
    result = urlfetch.fetch(url)
    if result.status_code == 200:
        name = fileName
        mtype = result.headers.get('Content-Type', '')
        bits = result.content
        gf=GaeFile()
        gf.open(name,mtype);
        gf.write(bits)
        id=gf.close()
        
        image=Images(description="/media/?key="+str(id))
        image.mime=result.headers.get('Content-Type', '')
        image.filetype=image.mime
        # if image.mime.find('image')==-1:
            # return None
        image.size=len(bits)
        image.width=-1;
        image.height=-1;
        # image.name=fileName
        # image.filetype,image.width,image.height=getImageInfo(image.bf)
        image.tag=tag.split(',')
        image.put()
        AddTags(image.tag)
        return image
    else:
        return None
예제 #2
0
def addImage2(bf):
    image = Images(bf=bf)
    image.size = len(bf)
    image.filetype, image.width, image.height = getImageInfo(bf)
    if not image.filetype: return None
    image.mime = image.filetype
    image.put()
    return image
예제 #3
0
def addImage2(bf):
    image=Images(bf=bf)
    image.size=len(bf)
    image.filetype,image.width,image.height=getImageInfo(bf)
    if not image.filetype:return None
    image.mime=image.filetype
    image.put()
    return image
예제 #4
0
def addImage(title, bf, referer):
    'Add Image'
    image = Images(description=title, bf=bf, referer=referer)
    image.size = len(image.bf)
    image.filetype, image.width, image.height = getImageInfo(bf)
    if not image.filetype: return None
    image.mime = image.filetype

    image.put()
    return image
예제 #5
0
파일: methods.py 프로젝트: fireyy/pyasaph
def addImage(title,bf,referer):
    'Add Image'
    image=Images(description=title,bf=bf,referer=referer)
    image.size=len(image.bf)
    image.filetype,image.width,image.height=getImageInfo(bf)
    if not image.filetype:return None
    image.mime=image.filetype
    
    image.put()
    return image
예제 #6
0
def addImage2(bf):
    image=Images()
    image.size=len(bf)
    image.filetype,image.width,image.height=getImageInfo(bf)
    if not image.filetype:return None
    image.mime=image.filetype
    image.put()
    
    imageblob = ImageBlob(image=image, bf=bf)
    imageblob.put()
    
    prependToRSS([image])
    
    return image
예제 #7
0
def AddImageByUrlBak(url,fileName,tag):
    result = urlfetch.fetch(url)
    if result.status_code == 200:
        image=Images(description=url,bf=result.content)
        image.mime=result.headers.get('Content-Type', '')
        if image.mime.find('image')==-1:
            return None
        image.size=len(image.bf)
        image.name=fileName
        image.filetype,image.width,image.height=getImageInfo(image.bf)
        image.tag=tag.split(',')
        image.put()
        AddTags(image.tag)
        return image
    else:
        return None