Пример #1
0
 def close(self):
     image=self.store.returnHandle().get_file_image().encode('base64','strict')
     env=os.environ.copy()
     usr=env["USRGILGA"]
     with create_engine('postgresql://*****:*****@localhost/ishtar').begin() as db:
         pgquery.save_file(db, usr, '/export/'+self.fileName, image, 0)     
     self.store.close()
Пример #2
0
 def post(self): 
     usr= tornado.escape.xhtml_escape(self.current_user)
     #print "I got a request!"
     #print self.request.arguments
     file='/'+self.get_argument("file")
     name=split_api_filepath(file)[1]
     db=create_engine('postgresql://*****:*****@localhost/ishtar')
     binarycontent=pgquery.get_file(db, usr, file, include_content=True)['content'] 
     db.dispose()
     with create_engine('postgresql://*****:*****@localhost/ishtar').begin() as db:
         pgquery.save_file(db, 'share', '/export/'+name, binarycontent, 0)
Пример #3
0
        def post(self): 
            name = tornado.escape.xhtml_escape(self.current_user)
            path=self.get_argument("path")
            directory=self.get_argument("directory")
            if directory[-1] != '/':
                directory=directory+'/'

            db=create_engine('postgresql://*****:*****@localhost/ishtar')
            binarycontent=pgquery.get_file(db, "share", path, include_content=True)['content']   
            db.dispose()
            with create_engine('postgresql://*****:*****@localhost/ishtar').begin() as db:
                pgquery.save_file(db, name, directory+split_api_filepath(path)[1], binarycontent, 0)
            self.redirect('/shared')
Пример #4
0
def save(data, path, format='text'):
    """将文件存储在指定目录下"""
    if format not in ['text', 'base64', 'bytes']:
        print("Unexcept format type: %s." % (format))
        return
    if not path.startswith("/"):
        path = rela2abs(path)
    directory, name = split_api_filepath(path)
    user_id = os.environ.get("JUPYTERHUB_USER") or ""

    content = b64encode(data) if format == 'bytes' else to_b64(data, format)

    with get_engine().begin() as db:
        save_file(db, user_id, path, content, crypto.NoEncryption().encrypt, 0)