Changeset View
Changeset View
Standalone View
Standalone View
src/future/aws/PhutilAWSS3Future.php
Show All 20 Lines | public function setParametersForGetObject($key) { | ||||
$bucket = $this->getBucket(); | $bucket = $this->getBucket(); | ||||
$this->setHTTPMethod('GET'); | $this->setHTTPMethod('GET'); | ||||
$this->setPath($bucket.'/'.$key); | $this->setPath($bucket.'/'.$key); | ||||
return $this; | return $this; | ||||
} | } | ||||
public function setParametersForPutObject($key, $value) { | |||||
$bucket = $this->getBucket(); | |||||
$this->setHTTPMethod('PUT'); | |||||
$this->setPath($bucket.'/'.$key); | |||||
$this->addHeader('X-Amz-ACL', 'private'); | |||||
$this->addHeader('Content-Type', 'application/octet-stream'); | |||||
$this->setData($value); | |||||
return $this; | |||||
} | |||||
public function setParametersForDeleteObject($key) { | |||||
$bucket = $this->getBucket(); | |||||
$this->setHTTPMethod('DELETE'); | |||||
$this->setPath($bucket.'/'.$key); | |||||
return $this; | |||||
} | |||||
protected function didReceiveResult($result) { | protected function didReceiveResult($result) { | ||||
list($status, $body, $headers) = $result; | list($status, $body, $headers) = $result; | ||||
if (!$status->isError()) { | if (!$status->isError()) { | ||||
return $body; | return $body; | ||||
} | } | ||||
if ($status->getStatusCode() === 404) { | if ($status->getStatusCode() === 404) { | ||||
return null; | return null; | ||||
} | } | ||||
return parent::didReceiveResult($result); | return parent::didReceiveResult($result); | ||||
} | } | ||||
} | } |