本文整理汇总了PHP中AmazonS3::put方法的典型用法代码示例。如果您正苦于以下问题:PHP AmazonS3::put方法的具体用法?PHP AmazonS3::put怎么用?PHP AmazonS3::put使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AmazonS3
的用法示例。
在下文中一共展示了AmazonS3::put方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPut
/**
* @covers mychaelstyle\storage\providers\AmazonS3::put
* @covers mychaelstyle\storage\providers\AmazonS3::remove
* @covers mychaelstyle\storage\providers\AmazonS3::__mergePutOptions
* @covers mychaelstyle\storage\providers\AmazonS3::__formatUri
*/
public function testPut()
{
if ($this->markIncompleteIfNoNetwork()) {
return true;
}
$expected = file_get_contents($this->path_example);
// put a example file
$options = array('contentType' => 'text/plain;charset=UTF8');
$this->object->put($this->path_example, $this->uri, $options);
$options = array('contentType' => 'text/plain');
$options['contentType'] = null;
$options['acl'] = 'private';
//$options['curl.options'] = array(CURLOPT_SSL_VERIFYPEER => false);
$this->object->put($this->path_example, $this->uri, $options);
}
示例2: testPutWithMoreHeaders
/**
* testPutWithMoreHeaders
*
* @return void
* @author Rob Mcvey
**/
public function testPutWithMoreHeaders()
{
$file_path = APP . 'Plugin' . DS . 'AmazonS3' . DS . 'Test' . DS . 'test_app' . DS . 'webroot' . DS . 'files' . DS . 'dots.csv';
$this->AmazonS3->setDate('Mon, 23 Sep 2013 08:46:05 GMT');
// Mock the built request
$expectedRequest = array('method' => 'PUT', 'uri' => array('host' => 'bucket.s3.amazonaws.com', 'scheme' => 'https', 'path' => 'some/dir/in/the/bucket/dots.csv'), 'header' => array('Accept' => '*/*', 'User-Agent' => 'CakePHP', 'Date' => 'Mon, 23 Sep 2013 08:46:05 GMT', 'Authorization' => 'AWS foo:WxdnOvuaK37BwO72xShLSFu80LI=', 'Content-MD5' => 'L0O0L9gz0ed0IKja50GQAA==', 'Content-Type' => 'text/plain', 'Content-Length' => 3, 'X-Amz-Meta-ReviewedBy' => 'john.doe@yahoo.biz', 'x-amz-acl' => 'public-read'), 'body' => '...');
// Mock the HttpSocket response
$HttpSocketResponse = new stdClass();
$HttpSocketResponse->body = '????JFIFdd??Duckya??Adobed??????????';
$HttpSocketResponse->code = 200;
$HttpSocketResponse->reasonPhrase = 'OK';
$HttpSocketResponse->headers = array('x-amz-id-2' => '4589328529385938', 'x-amz-request-id' => 'GSDFGt45egdfsC', 'Date' => 'Mon, 23 Sep 2013 08:46:05 GMT', 'Last-Modified' => 'Tue, 29 Nov 2011 10:30:03 GMT', 'ETag' => '24562346dgdgsdgf2352"', 'Accept-Ranges' => 'bytes', 'Content-Type' => 'image/jpeg', 'Content-Length' => 0, 'Connection' => 'close', 'Server' => 'AmazonS3');
// Mock the HttpSocket class
$this->AmazonS3->HttpSocket = $this->getMock('HttpSocket');
$this->AmazonS3->HttpSocket->expects($this->once())->method('request')->with($expectedRequest)->will($this->returnValue($HttpSocketResponse));
$this->AmazonS3->amazonHeaders = array('x-amz-acl' => 'public-read', 'X-Amz-Meta-ReviewedBy' => 'john.doe@yahoo.biz');
$this->AmazonS3->put($file_path, '/some/dir/in/the/bucket/');
}