-
Notifications
You must be signed in to change notification settings - Fork 23
feat(file): new file key mechanism #220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
本地跑 File 相关测试均通过: $ vendor/bin/phpunit test/FileTest.php
PHPUnit 5.7.27 by Sebastian Bergmann and contributors.
........... 11 / 11 (100%)
Time: 24.04 seconds, Memory: 4.00MB
OK (11 tests, 30 assertions)CI 里测试不过是已知问题,和本 pr 无关。等 #217 解决后再 rebase 下本 pr 应该就能都通过了。 Update: 上面的测试指去掉 |
da464e3 to
1557b63
Compare
1557b63 to
eb11294
Compare
| LEANCLOUD_API_SERVER: https://us.avoscloud.com | ||
| LEANCLOUD_APP_ID: wnDg0lPt0wcYGJSiHRwHBhD4 | ||
| LEANCLOUD_APP_KEY: u9ekx9HFSFFBErWwyWHFmPDy | ||
| LEANCLOUD_APP_MASTER_KEY: ${{ secrets.MASTER_KEY }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
从设计上说 master key 应该保密,另外也 git grep 了一下之前没有在代码或配置文件中泄露过这个 master key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是的,之前是在 ci 上面设置的环境变量。
| */ | ||
| public function __construct($name, $data=null, $mimeType=null) { | ||
| $this->_data["name"] = $name; | ||
| $this->_data["key"] = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
加了一个 key 属性,供用户指定 key
| if ($this->isExternal()) { | ||
| $data["url"] = $this->getUrl(); | ||
| $resp = Client::post("/files/{$this->getName()}", $data); | ||
| $resp = Client::post("/files", $data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
api 那边计划废弃 POST /files/:name 接口
| $key = static::genFileKey(); | ||
| $key = "{$key}." . pathinfo($this->getName(), PATHINFO_EXTENSION); | ||
| $data["key"] = $key; | ||
| $key = $this->getKey(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SDK 不再生成 key,用户指定了,就传过去,否则不传
| $this->assertEmpty($file->getObjectId()); | ||
| } | ||
|
|
||
| public function testSaveExternalFile() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
之前没有保存外部文件的测试,加了一下。
| getenv("LEANCLOUD_APP_ID"), | ||
| getenv("LEANCLOUD_APP_KEY"), | ||
| getenv("LEANCLOUD_APP_MASTER_KEY")); | ||
| Client::useMasterKey(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
新开一个类,专门测试需要 master 权限的接口。
- New intl. applications share a gluttony bucket. - Users may use `/` in the specified key.
weakish
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GitHub 现在强制必须留一条总的评论,否则不让提交 inline 评论。这设计明显不合理啊。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
改了一下测试(之前没考虑国际版新一代的饕餮应用)。
| $gluttonyPath = "/" + substr(getenv("LEANCLOUD_APP_KEY"), 0, 12) + "/abc"; | ||
| $this->assertEquals($gluttonyPath, $path); | ||
| } else { | ||
| $this->assertEquals("/abc", $path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
正常情况在这里,上面两个分支是为了兼容国际版很老的应用以及比较新的使用饕餮之桶的应用。
juvenn
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
| LEANCLOUD_API_SERVER: https://us.avoscloud.com | ||
| LEANCLOUD_APP_ID: wnDg0lPt0wcYGJSiHRwHBhD4 | ||
| LEANCLOUD_APP_KEY: u9ekx9HFSFFBErWwyWHFmPDy | ||
| LEANCLOUD_APP_MASTER_KEY: ${{ secrets.MASTER_KEY }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是的,之前是在 ci 上面设置的环境变量。
No description provided.