public function testPutWithPersistentOps() { $key = 'testPutWithPersistentOps' . getTid(); $err = RSUtils::Qiniu_RS_Delete($this->client, $this->bucket, $key); $putPolicy = new QiniuRSPutPolicy($this->bucket); $putPolicy->PersistentOps = 'avthumb/mp3'; $putPolicy->PersistentNotifyUrl = 'http://someurl/abc'; $upToken = $putPolicy->Token(null); list($ret, $err) = QiniuPutExtra::Qiniu_Put($upToken, $key, "hello world!", null); $this->assertNull($err); $this->assertArrayHasKey('hash', $ret); $this->assertArrayHasKey('persistentId', $ret); var_dump($ret); list($ret, $err) = RSUtils::Qiniu_RS_Stat($this->client, $this->bucket, $key); $this->assertNull($err); var_dump($ret); $err = RSUtils::Qiniu_RS_Delete($this->client, $this->bucket, $key); $this->assertNull($err); }
static function Qiniu_RS_Put($self, $bucket, $key, $body, $putExtra) { $putPolicy = new QiniuRSPutPolicy("{$bucket}:{$key}"); $upToken = $putPolicy->Token($self->Mac); return QiniuPutExtra::Qiniu_Put($upToken, $key, $body, $putExtra); }
public function testPut_exclusive() { $key = 'testPut_exclusive' . getTid(); $scope = $this->bucket . ':' . $key; $err = RSUtils::Qiniu_RS_Delete($this->client, $this->bucket, $key); $putPolicy = new QiniuRSPutPolicy($scope); $putPolicy->InsertOnly = 1; $upToken = $putPolicy->Token(null); list($ret, $err) = QiniuPutExtra::Qiniu_Put($upToken, $key, "hello world!", null); $this->assertNull($err); list($ret, $err) = QiniuPutExtra::Qiniu_PutFile($upToken, $key, __FILE__, null); $this->assertNull($ret); $this->assertEquals($err->Code, 614); var_dump($err); list($ret, $err) = RSUtils::Qiniu_RS_Stat($this->client, $this->bucket, $key); $this->assertNull($err); $this->assertEquals($ret['mimeType'], 'application/octet-stream'); var_dump($ret); $err = RSUtils::Qiniu_RS_Delete($this->client, $this->bucket, $key); $this->assertNull($err); }