Amazon AWS SDK Installation Guide Page 144

  • Download
  • Add to my manuals
  • Print
  • Page
    / 151
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 143
}
// Be sure to close the stream resource when you're done with it
fclose($stream);
}
Opening Seekable streams
Streams opened in "r" mode only allow data to be read from the stream, and are not seekable by default. This is so
that data can be downloaded from Amazon S3 in a truly streaming manner where previously read bytes do not need
to be buffered into memory. If you need a stream to be seekable, you can pass seekable into the stream context
options of a function.
$context = stream_context_create(array(
's3' => array(
'seekable' => true
)
));
if ($stream = fopen('s3://bucket/key', 'r', false, $context)) {
// Read bytes from the stream
fread($stream, 1024);
// Seek back to the beginning of the stream
fseek($steam, 0);
// Read the same bytes that were previously read
fread($stream, 1024);
fclose($stream);
}
Opening seekable streams allows you to seek only to bytes that were previously read. You cannot skip ahead to
bytes that have not yet been read from the remote server. In order to allow previously read data to recalled, data is
buffered in a PHP temp stream using Guzzle's CachingEntityBody decorator. When the amount of cached data
exceed 2MB, the data in the temp stream will transfer from memory to disk. Keep this in mind when downloading
large files from Amazon S3 using the seekable stream context setting.
Uploading data
Data can be uploaded to Amazon S3 using file_put_contents().
file_put_contents('s3://bucket/key', 'Hello!');
You can upload larger files by streaming data using fopen() and a "w", "x", or "a" stream access mode. The
Amazon S3 stream wrapper does not support simultaneous read and write streams (e.g. "r+", "w+", etc). This is
because the HTTP protocol does not allow simultaneous reading and writing.
$stream = fopen('s3://bucket/key', 'w');
fwrite($stream, 'Hello!');
fclose($stream);
Note
Because Amazon S3 requires a Content-Length header to be specified before the payload of a request is sent,
the data to be uploaded in a PutObject operation is internally buffered using a PHP temp stream until the stream
is flushed or closed.
fopen modes
Amazon S3 Stream Wrapper
132
Page view 143

Comments to this Manuals

No comments

Indesit K3G51S(W)/HU S manuels

Manuels d'utilisation et guides de l'utilisateur pour Micro-ondes Indesit K3G51S(W)/HU S.
Nous fournissons des manuels en pdf 1 Indesit K3G51S(W)/HU S à télécharger gratuitement par type de document : Mode d'emploi






Plus de produits et de manuels pour Micro-ondes Indesit

Modèles Type de document
FN 56 XA S Mode d'emploi       Indesit FN 56 XA S Instruction for Use, 60 pages
FIM 832J K.A IX (PL) Mode d'emploi       Indesit FIM 832J K.A IX (PL) Instruction for Use [es] , 84 pages
FK 63 X/HA S Mode d'emploi      Indesit FK 63 X/HA S Instruction for Use, 52 pages
7OFHR 640 (AN)RU/HA Mode d'emploi    Indesit 7OFHR 640 (AN)RU/HA Instruction for Use [de] [fr] , 20 pages
FH 51 (WH)/HA S Mode d'emploi        Indesit FH 51 (WH)/HA S Instruction for Use [et] [nl] , 52 pages
IF 88 K GP.A IX S Mode d'emploi        Indesit IF 88 K GP.A IX S Instruction for Use [es] , 64 pages
7OIF 617 K.A IX RU Mode d'emploi   Indesit 7OIF 617 K.A IX RU Instruction for Use, 20 pages
FHR 540 (AN)/HA S Mode d'emploi       Indesit FHR 540 (AN)/HA S Instruction for Use [nl] , 56 pages
CP87SG1 /HA Mode d'emploi       Indesit CP87SG1 /HA Instruction for Use, 64 pages
UT 89 S P X/HA Mode d'emploi       Indesit UT 89 S P X/HA Instruction for Use, 56 pages
EHS 53 KX/HA Mode d'emploi    Indesit EHS 53 KX/HA Instruction for Use [fr] , 20 pages
I5G62AG(W)/UA Mode d'emploi    Indesit I5G62AG(W)/UA Instruction for Use [ua] , 24 pages
FIMS 20 K.A AX S Mode d'emploi        Indesit FIMS 20 K.A AX S Instruction for Use, 60 pages
FIMS 20 K.A AX S Mode d'emploi        Indesit FIMS 20 K.A AX S Instruction for Use, 60 pages
FHS 21 IX/HA S Mode d'emploi         Indesit FHS 21 IX/HA S Instruction for Use, 68 pages
KN6G660SA(W)/U S Mode d'emploi     Indesit KN6G66SA(X)/U S Instruction for Use, 64 pages
I6VV2A(X)/EX Mode d'emploi      Indesit I6VV2A(X)/EX Instruction for Use [de] , 58 pages
BIG 73 J KC.A IX GB Mode d'emploi   Indesit BIG 73 J KC.A IX GB Instruction for Use [fr] , 16 pages
FIE 76 KC.A IX GB Mode d'emploi   Indesit FIE 76 KC.A IX GB Instruction for Use [da] [it] , 12 pages
XF 995.3 /HA Mode d'emploi       Indesit XF 995.3 /HA Instruction for Use [fr] , 52 pages