Beispiel #1
0
  def get(self, cluster, environ, topology, container):

    # If the file is large, we want to abandon downloading
    # if user cancels the requests.
    self.connection_closed = False

    path = self.get_argument("path")
    filename = path.split("/")[-1]
    self.set_header("Content-Disposition", "attachment; filename=%s" % filename)

    # Download the files in chunks. We are downloading from Tracker,
    # which in turns downloads from heron-shell. This much indirection
    # means that if we use static file downloading, the whole files would
    # be cached in memory before it can be sent downstream. Hence, we reuse
    # the file data API to read in chunks until the EOF, or until the download
    # is cancelled by user.

    # 4 MB gives good enough chunk size giving good speed for small files.
    # If files are large, a single threaded download may not be enough.
    length = 4 * 1024 * 1024
    offset = 0
    while True:
      response = yield access.get_container_file_data(cluster, environ, topology, container, path, offset, length)
      if self.connection_closed or 'data' not in response or len(response['data']) < length:
        break
      offset += length
      self.write(response['data'])
      self.flush()

    self.write(response['data'])
    self.finish()
Beispiel #2
0
    def get(self, cluster, environ, topology, container):

        # If the file is large, we want to abandon downloading
        # if user cancels the requests.
        self.connection_closed = False

        path = self.get_argument("path")
        filename = path.split("/")[-1]
        self.set_header("Content-Disposition",
                        "attachment; filename=%s" % filename)

        # Download the files in chunks. We are downloading from Tracker,
        # which in turns downloads from heron-shell. This much indirection
        # means that if we use static file downloading, the whole files would
        # be cached in memory before it can be sent downstream. Hence, we reuse
        # the file data API to read in chunks until the EOF, or until the download
        # is cancelled by user.

        # 4 MB gives good enough chunk size giving good speed for small files.
        # If files are large, a single threaded download may not be enough.
        length = 4 * 1024 * 1024
        offset = 0
        while True:
            response = yield access.get_container_file_data(
                cluster, environ, topology, container, path, offset, length)
            if self.connection_closed or 'data' not in response or len(
                    response['data']) < length:
                break
            offset += length
            self.write(response['data'])
            self.flush()

        self.write(response['data'])
        self.finish()
Beispiel #3
0
  def get(self, cluster, environ, topology, container):

    offset = self.get_argument("offset")
    length = self.get_argument("length")
    path = self.get_argument("path")

    data = yield access.get_container_file_data(cluster, environ, topology, container, path, offset, length)

    self.write(data)
    self.finish()
Beispiel #4
0
    def get(self, cluster, environ, topology, container):

        offset = self.get_argument("offset")
        length = self.get_argument("length")
        path = self.get_argument("path")

        data = yield access.get_container_file_data(cluster, environ, topology,
                                                    container, path, offset,
                                                    length)

        self.write(data)
        self.finish()