Ejemplo n.º 1
0
    def get(self, reference):
        logging.debug("Requesting file %s" % reference)
        if not tools.validate_reference(reference):
            raise tornado.web.HTTPError(404)

        filename, filesize, description, db_uploadid = \
            self._locate_upload(reference)

        if filename is None or filesize is None or description is None:
            raise tornado.web.HTTPError(404)

        filesize, units = tools.format_filesize(filesize)

        reference = tornado.escape.xhtml_escape(reference)
        self.render("fileinfo.html", filename=filename, 
                    filesize=filesize, units=units, 
                    reference=reference, description=description)
Ejemplo n.º 2
0
    def get(self, reference):
        logging.debug("Requesting file %s" % reference)
        if not tools.validate_reference(reference):
            raise tornado.web.HTTPError(404)

        filename, filesize, description, db_uploadid = \
            self._locate_upload(reference)

        if filename is None or filesize is None or description is None:
            raise tornado.web.HTTPError(404)

        filesize, units = tools.format_filesize(filesize)

        reference = tornado.escape.xhtml_escape(reference)
        self.render("fileinfo.html",
                    filename=filename,
                    filesize=filesize,
                    units=units,
                    reference=reference,
                    description=description)
Ejemplo n.º 3
0
    def get(self, reference, filename):
        # Fixme? if no default and argument not found fw raises 404 :/
        token = self.get_argument("token", default=None)
        if token is None:
            raise tornado.web.HTTPError(400)

        logging.debug("Downloading file %s as %s" % (reference, filename))
        if not tools.validate_reference(reference):
            raise tornado.web.HTTPError(404)

        if not self._validate_token(token):
            logging.debug("Token %s is no longer valid to get %s" %
                        (token, reference))
            raise tornado.web.HTTPError(403)
        
        filesize, local_fileid, content_type = self._lookup_upload(reference)

        if filesize is None or local_fileid is None or content_type is None:
            raise tornado.web.HTTPError(404)

        path = "/".join([options.storage, local_fileid])
        logging.debug("About to deliver : %s, Size: %s C-T: %s" % 
                (path, filesize, content_type))

        self._set_token_in_use(token)

        self.set_header("Content-Length", filesize)
        self.set_header("Content-Type", content_type)

        in_file = open(path, "r")
        buf = in_file.read(100)
        # Todo: EOF flag in in_file?
        while buf != "":
            self.write(buf)
            buf = in_file.read(100)
        in_file.close()

        self.flush()
        self._set_token_redeemed(token)
Ejemplo n.º 4
0
    def get(self, reference, filename):
        # Fixme? if no default and argument not found fw raises 404 :/
        token = self.get_argument("token", default=None)
        if token is None:
            raise tornado.web.HTTPError(400)

        logging.debug("Downloading file %s as %s" % (reference, filename))
        if not tools.validate_reference(reference):
            raise tornado.web.HTTPError(404)

        if not self._validate_token(token):
            logging.debug("Token %s is no longer valid to get %s" %
                          (token, reference))
            raise tornado.web.HTTPError(403)

        filesize, local_fileid, content_type = self._lookup_upload(reference)

        if filesize is None or local_fileid is None or content_type is None:
            raise tornado.web.HTTPError(404)

        path = "/".join([options.storage, local_fileid])
        logging.debug("About to deliver : %s, Size: %s C-T: %s" %
                      (path, filesize, content_type))

        self._set_token_in_use(token)

        self.set_header("Content-Length", filesize)
        self.set_header("Content-Type", content_type)

        in_file = open(path, "r")
        buf = in_file.read(100)
        # Todo: EOF flag in in_file?
        while buf != "":
            self.write(buf)
            buf = in_file.read(100)
        in_file.close()

        self.flush()
        self._set_token_redeemed(token)