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
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
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
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
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
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
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