Amazon AWS SDK Guia de Instalação Página 43

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 151
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 42
// 2. Prepare
$command->prepare();
$request = $command->getRequest();
// Note: `prepare()` also returns the request object
// 3. Execute
$command->execute();
$response = $command->getResponse();
$result = $command->getResult();
// Note: `execute()` also returns the result object
This is nice, because it gives you a chance to modify the request before it is actually sent.
$command = $client->getCommand('OperationName');
$request = $command->prepare();
$request->addHeader('foo', 'bar');
$result = $command->execute();
You don't have to manage each aspect of the state though, calling execute() will also prepare the command, and
calling getResult() will prepare and execute the command.
Using requests and responses
Request and response objects contain data about the actual requests and responses to the service.
$command = $client->getCommand('OperationName');
$command->execute();
// Get and use the request object
$request = $command->getRequest();
$contentLength = $request->getHeader('Content-Length');
$url = $request->getUrl();
// Get and use the response object
$response = $command->getResponse();
$success = $response->isSuccessful();
$status = $response->getStatusCode();
You can also take advantage of the __toString behavior of the request and response objects. If you print them
(e.g., echo $request;), you can see the raw request and response data that was sent over the wire.
To learn more, read the API docs for the Request and Response classes.
Executing commands in parallel
The AWS SDK for PHP allows you to execute multiple operations in parallel when you use command objects. This
can reduce the total time (sometimes drastically) it takes to perform a set of operations, since you can do them at
the same time instead of one after another. The following shows an example of how you could upload two files to
Amazon S3 at the same time.
$commands = array();
$commands[] = $s3Client->getCommand('PutObject', array(
'Bucket' => 'SOME_BUCKET',
'Key' => 'photos/photo01.jpg',
'Body' => fopen('/tmp/photo01.jpg', 'r'),
));
$commands[] = $s3Client->getCommand('PutObject', array(
'Bucket' => 'SOME_BUCKET',
'Key' => 'photos/photo02.jpg',
'Body' => fopen('/tmp/photo02.jpg', 'r'),
));
Command Objects
31
Vista de página 42
1 2 ... 38 39 40 41 42 43 44 45 46 47 48 ... 150 151

Comentários a estes Manuais

Sem comentários

Dell W3000 TV Handbücher

Bedienungsanleitungen und Benutzerhandbücher für Computerzubehör Dell W3000 TV.
Wir stellen 3 PDF-Handbücher Dell W3000 TV zum kostenlosen herunterladen nach Dokumenttypen zur Verfügung Bedienungsanleitung






Weitere Produkte und Handbücher für Computerzubehör Dell

Modelle Dokumententyp
Premium Lock Bedienungsanleitung   Инструкция по эксплуатации Dell Premium Lock, 1 Seiten
Combination Lock Bedienungsanleitung    Инструкция по эксплуатации Dell Combination Lock, 1 Seiten
Entry Lock Bedienungsanleitung    Инструкция по эксплуатации Dell Entry Lock, 1 Seiten
Portable Power Companion (12000mAh) PW7015M Bedienungsanleitung   Dell Portable Power Companion (12000mAh) PW7015M User Manual, 1 Seiten
Wireless Mouse WM324 Bedienungsanleitung    Dell Wireless Mouse WM324 Manuel d'utilisation, 2 Seiten