Exemplo n.º 1
0
  def _RunFileFinderDownloadHello(self, upload, opts=None):
    action = rdf_file_finder.FileFinderAction.Download()
    action.download = opts

    upload.return_value = rdf_client.UploadedFile(
        bytes_uploaded=42, file_id="foo", hash=rdf_crypto.Hash())

    hello_path = os.path.join(self.base_path, "hello.exe")
    return self._RunFileFinder([hello_path], action)
Exemplo n.º 2
0
  def UploadFile(self, args):
    """Just copy the file into the filestore."""
    file_fd = vfs.VFSOpen(args.pathspec)

    fs = file_store.FileUploadFileStore()
    fd = fs.CreateFileStoreFile()
    while True:
      data = file_fd.read(self.BUFFER_SIZE)
      if not data:
        break
      fd.write(data)
    file_id = fd.Finalize()

    return [rdf_client.UploadedFile(stat_entry=file_fd.Stat(), file_id=file_id)]