Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
MongoDB::GridFSBucket:UsernContributedMPngoDB::GridFSBucket::DownloadStream(3)

NAME
       MongoDB::GridFSBucket::DownloadStream - File handle abstraction for
       downloading

VERSION
       version v1.8.0

SYNOPSIS
	   # OO	API
	   $stream = $bucket->open_download_stream($file_id)
	   while ( my $line = $stream->readline	) {
	       ...
	   }

	   # Tied-handle API
	   $fh = $stream->fh;
	   while ( my $line = <$fh> ) {
	       ...
	   }

DESCRIPTION
       This class provides a file abstraction for downloading.	You can	stream
       data from an object of this class using method calls or a tied-handle
       interface.

ATTRIBUTES
   file_doc
       The file	document for the file to be downloaded.

       Valid file documents typically include the following fields:

       o   _id a a unique ID for this document,	typically a MongoDB::OID
	   object. Legacy GridFS files may store this value as a different
	   type.

       o   length a the	length of this stored file, in bytes

       o   chunkSize a the size, in bytes, of each full	data chunk of this
	   file.

       o   uploadDate a	the date and time this file was	added to GridFS,
	   stored as a BSON datetime value and inflated	per the	bucket's
	   bson_codec attribute.

       o   md5 a a hash	of the contents	of the stored file

       o   filename a the name of this stored file; this does not need to be
	   unique

       o   metadata a any additional application-specific data

       o   contentType a DEPRECATED

       o   aliases a DEPRECATED

METHODS
   fh
	   my $fh = $downloadstream->fh;
	   while ( <$fh> ) {
	       say($_);
	   }

       Returns a new Perl file handle tied to this instance of DownloadStream
       that can	be operated on with the	built-in functions "read", "readline",
       "getc", "eof", "fileno" and "close".

       Important notes:

       Allowing	one of these tied filehandles to fall out of scope will	NOT
       cause close to be called. This is due to	the way	tied file handles are
       implemented in Perl.  For close to be called implicitly,	all tied
       filehandles and the original object must	go out of scope.

       Each file handle	retrieved this way is tied back	to the same object, so
       calling close on	multiple tied file handles and/or the original object
       will have the same effect as calling close on the original object
       multiple	times.

   close
	   $stream->close

       Works like the builtin "close".

       Important notes:

       o   Calling close will also cause any tied file handles created for the
	   stream to also close.

       o   "close" will	be automatically called	when a stream object is
	   destroyed.

       o   Calling "close" repeately will warn.

   eof
	   if (	$stream->eof() ) { ... }

       Works like the builtin "eof".

   fileno
	   if (	$stream->fileno() ) { ... }

       Works like the builtin "fileno",	but it returns -1 if the stream	is
       open and	undef if closed.

   getc
	   $char = $stream->getc();

       Works like the builtin "getc".

   read
	   $data = $stream->read($buf, $length,	$offset)

       Works like the builtin "read".

   readline
	   $line  = $stream->readline();
	   @lines = $stream->readline();

       Works like the builtin "readline".

AUTHORS
       o   David Golden	<david@mongodb.com>

       o   Rassi <rassi@mongodb.com>

       o   Mike	Friedman <friedo@friedo.com>

       o   Kristina Chodorow <k.chodorow@gmail.com>

       o   Florian Ragwitz <rafl@debian.org>

COPYRIGHT AND LICENSE
       This software is	Copyright (c) 2017 by MongoDB, Inc.

       This is free software, licensed under:

	 The Apache License, Version 2.0, January 2004

perl v5.24.1			  2017MongoDB::GridFSBucket::DownloadStream(3)

NAME | VERSION | SYNOPSIS | DESCRIPTION | ATTRIBUTES | METHODS | AUTHORS | COPYRIGHT AND LICENSE

Want to link to this manual page? Use this URL:
<https://www.freebsd.org/cgi/man.cgi?query=MongoDB::GridFSBucket::DownloadStream&sektion=3&manpath=FreeBSD+12.1-RELEASE+and+Ports>

home | help