Set the stream which this uploaded file refers to.
333455
public function setStream(PsrStreamInterface $stream)
	{
		$this->stream = $stream;
		$this->error = UPLOAD_ERR_OK;
		
		return true;
	}
389393
def set_stream(source, options)
      # Are we going to read from a file, or read from a binary string?
      if options[:bin]
        # Read from the provided binary string:
        @str = source
      else
        # Read from file:
        open_file(source)
        # Read the initial header of the file:
        if @file == nil
          # File is not readable, so we return:
          @success = false
          return
        else
          # Extract the content of the file to a binary string:
          @str = @file.read
          @file.close
        end
      end

      # Create a Stream instance to handle the decoding of content from this binary string:
      @file_endian = false
      @stream = Stream.new(@str, false)
    end
997792
def put_stream(self, rel_path, metadata=None, cb=None):
        ''' '''

        import Queue
        import time
        import threading

        md5 = metadata.get('md5', None) if metadata else None

        # Horrible, but doing it anyway because I can.
        acl = ('public-read' if metadata.get('public',
                                             False) else metadata.get('acl',
                                                                      'public-read')) if metadata else 'public-read'

        path = self._prefix(self._rename(rel_path))

        class ThreadUploader(threading.Thread):

            """Thread class for uploading a part to S3"""

            def __init__(self, n, queue):
                threading.Thread.__init__(self)
                self.n = n
                self.queue = queue

            def run(self):

                while True:
                    mp, part_number, buf = self.queue.get()
                    if mp is None:  # Signal to die
                        logger.debug(
                            "put_stream: Thread {} exiting".format(
                                self.n))
                        self.queue.task_done()
                        return
                    logger.debug(
                        "put_stream: Thread {}: processing part: {}".format(
                            self.n,
                            part_number))
                    t1 = time.time()
                    try:
                        mp.upload_part_from_file(buf, part_number)
                    finally:
                        self.queue.task_done()
                        t2 = time.time()
                        logger.debug("put_stream: Thread {}, part {}. time = {} rate =  {} b/s" .format(
                            self.n, part_number, round(t2 - t1, 3), round((float(buf.tell()) / (t2 - t1)), 2)))

        if metadata is None:
            metadata = {}

        if md5:
            metadata['md5'] = md5  # Multipart uploads don't use md5 for etag

        # Some libraries, including apparently, boto, have troubles properly calcing the hash when
        # metadata values are null, empty, 0, etc.
        # https://forums.aws.amazon.com/thread.jspa?threadID=117580
        for k, v in metadata.items():
            if not v:
                del metadata[k]

        this = self

        buffer_size = 50 * 1024 * 1024  # Min part size is 5MB
        num_threads = 4
        thread_upload_queue = Queue.Queue(maxsize=100)

        for i in range(num_threads):
            t = ThreadUploader(i, thread_upload_queue)
            t.setDaemon(True)
            t.start()

        class flo:

            '''Object that is returned to the caller, for the caller to issue
            write() or writeline() calls on '''

            def __init__(self, rel_path):
                import io

                self.mp = this.bucket.initiate_multipart_upload(
                    path,
                    metadata=metadata)
                self.part_number = 1
                self.buffer = io.BytesIO()
                self.total_size = 0

                self.rel_path = rel_path

            def _send_buffer(self):
                '''Schedules a buffer to be sent in a thread by queuing it'''
                logger.debug(
                    "_send_buffer: sending part {} to thread pool size: {}, total_size = {}" .format(
                        self.part_number,
                        self.buffer.tell(),
                        self.total_size))
                self.buffer.seek(0)
                thread_upload_queue.put(
                    (self.mp, self.part_number, self.buffer))

            def write(self, d):
                import io

                self.buffer.write(d)  # Load the requested data into a buffer
                self.total_size += len(d)
                # After the buffer is large enough, send it, then create a new
                # buffer.
                if self.buffer.tell() > buffer_size:
                    self._send_buffer()

                    self.part_number += 1
                    self.buffer = io.BytesIO()

            def writelines(self, lines):
                raise NotImplemented()

            def close(self):

                if self.buffer.tell() > 0:
                    self._send_buffer()

                # Wait for all of th upload to complete
                thread_upload_queue.join()

                for i in range(num_threads):
                    thread_upload_queue.put(
                        (None, None, None))  # Tell all of the threads to die

                # Wait for all of the threads to exit
                thread_upload_queue.join()

                # Multi-part uploads throw a 400 Bad Request if they are
                # completed without writing any data.
                if self.total_size > 0:
                    self.mp.complete_upload()

                    this.bucket.set_acl(acl, path)

                this.put_metadata(self.rel_path, metadata)

            def __enter__(self):
                return self

            def __exit__(self, type_, value, traceback):
                if type_:
                    return False

                self.close()

        return flo(rel_path)
1015184
protected function attachReadStream()
    {
        $this->ThrowOnConnectionInvalid();
        $this->loop->addReadStream($this->connection, function () {
            $this->readToBuffer();
        });
    }
779666
public void setFile(File file) throws FileNotFoundException{
		this.setInputStream(new BufferedInputStream(new FileInputStream(file)), file.length());
		this.isUploadFile = true;
	}
294762
public function setStream($streamName)
    {
        switch ($streamName) {
            case 'STDOUT':
                $this->stream = self::STDOUT;

                return;
            case 'STDERR':
                $this->stream = self::STDERR;

                return;
            default:
                LoggerPolicy::processConfigurationError("Stream must be STDOUT or STDERR, got '{$streamName}'");

                return;
        }
    }
633679
public void setProcessInputStream(OutputStream os) {
        if (input != null) {
            inputThread = createPump(input, os, true, nonBlockingRead);
        } else {
            try {
                os.close();
            } catch (IOException e) {
                //ignore
            }
        }
    }
1241820
public void file(String filename, InputStream input) {
        checkCommitted();

        // content type to OCTET_STREAM if it's not set
        if (getContentType() == null) {
            contentType(mimeTypes.getContentType(filename, HttpConstants.ContentType.APPLICATION_OCTET_STREAM));
        }

        if (isHeaderEmpty(HttpConstants.Header.CONTENT_DISPOSITION)) {
            filenameHeader(filename);
        }

        finalizeResponse();

        try {
            send(input);
        } catch (IOException e) {
            throw new PippoRuntimeException(e);
        }
    }
1067330
public void setPersistedFile(File file) throws FileNotFoundException
   {
      if (file instanceof SwapFile)
      {
         ((SwapFile)file).acquire(this);
      }

      this.file = file;

      // JCR-2326 Release the current ValueData from tempFile users before
      // setting its reference to null so it will be garbage collected.
      if (this.tempFile != null)
      {
         this.tempFile.release(this);
         this.tempFile = null;
      }

      this.stream = null;
   }
244670
def load(self, stream):
        

        # For the time being only accept file input streams
        if not _is_file(stream):
            raise TypeError('Argument should be a file object!')
        # Check for the opened mode
        if stream.mode != 'r':
            raise ValueError('Stream should be opened in read-only mode!')

        try:
            lines = stream.readlines()
            self.__parse(lines)
        except IOError:
            raise
883799
def stream(self):
        
        if self._stream is None:
            self._stream = tempfile.NamedTemporaryFile(delete=False)
            try:
               self._stream.write(self.client.open(self.filename, view='data').read())
            except:
               pass
        return self._stream
477253
def push_source(self, newstream, newfile=None):
        ""
        if isinstance(newstream, basestring):
            newstream = StringIO(newstream)
        self.filestack.appendleft((self.infile, self.instream, self.lineno))
        self.infile = newfile
        self.instream = newstream
        self.lineno = 1
542666
def update_contents(self, stream, seek=0, size=None, chunk_size=None,
                        progress_callback=None, **kwargs):
        
        self.checksum = None
        return self.storage(**kwargs).update(
            stream, seek=seek, size=size, chunk_size=chunk_size,
            progress_callback=progress_callback
        )
75402
def stream(self):
        """"""
        stream = self._p4dict.get('stream')
        if stream:
            return Stream(stream, self._connection)
1279913
def flush(self):
    """"""
    self.acquire()
    try:
      self.stream.flush()
    except (EnvironmentError, ValueError):
      # A ValueError is thrown if we try to flush a closed file.
      pass
    finally:
      self.release()
1286171
private void updateStreamPosition() throws IOException {
    try {
      editLogFilePosition = inputStream.getPosition();
    } catch (IOException e) {
      LOG.error("Failed to get edit log file position", e);
      throw new IOException("updateStreamPosition failed");
    }
  }
1189899
def rest_put_stream(self, url, stream, headers=None, session=None, verify=True, cert=None):
        
        res = session.put(url, headers=headers, data=stream, verify=verify, cert=cert)
        return res.text, res.status_code