Beispiel #1
0
    def post(self):
        img = self.request.files['uploadImg'][0]
        photo_desc = self.get_argument('photo_desc')
        thumb_dir = self.get_argument('node_Img')
        pid = self.fs.put(img['body'])
        img_size = Image.open(StringIO.StringIO(img['body'])).getbbox()
        user =json_decode(self.get_current_user())
        photo = {
           "uid":user['uid'],
           'pid':pid,
           'desc':photo_desc,
           'width':img_size[2],
           'height':img_size[3],
           'comment_num':0,
           'like':0,
           'upload_time':datetime.datetime.now()
        }
        self.db.photos.insert(photo)

        file_dir = self.site_path + thumb_dir 
        try:
            del_thumb(file_dir)
        except Exception,e:
            log.error(e)
            raise tornado.web.HTTPError(404,e)
Beispiel #2
0
 def post(self):
     thumb_dir = self.get_argument('thumb_dir')
     file_dir = self.site_path + thumb_dir 
     try:
         del_thumb(file_dir)
     except Exception,e:
         raise tornado.web.HTTPError(404,e)