def files_get(root, path_): tools.validate_root_or_abort(root) # Attempt to retrieve the database representation of the requested file # from the database, and raise a 404 if we failed in doing so. try: dbobject = database.get_stored_object(root, path_) except database.MissingNodeException: raise BasicError(404, E_FILE_NOT_FOUND) # Request the actual disk object to the file_store, and send the result as # a file to the client. fmdata = metadata.make_metadata(root, path_, dbobject) stream = file_store.retrieve_blob_stream(root, dbobject.hash) return _send_file(stream, path_, fmdata, dbobject.iv)
def files_get_key(key): db_ref = shares.retrieve_ref(urllib2.unquote(key)) fmdata = metadata.make_metadata(db_ref.root, db_ref.path, db_ref.blob) stream = file_store.retrieve_blob_stream(db_ref.root, db_ref.blob.hash) return _send_file(stream, db_ref.path, fmdata, db_ref.blob.iv)