Commit 609f6c88 authored by Dmitry Nikulin's avatar Dmitry Nikulin

Add support for building thumbnails URL

parent 7f1cc6ae
...@@ -52,6 +52,23 @@ Methods ...@@ -52,6 +52,23 @@ Methods
### getThumbnailUrl
string AttachmentsClient\AttachmentsClient::getThumbnailUrl(string $hash, $name)
Возвращает URL для миниатюры (thumbnail) изображения.
* Visibility: **public**
#### Arguments
* $hash **string** - <p>Хэш файла, полученный от метода загрузки.</p>
* $name **mixed**
### uploadFromFile ### uploadFromFile
string AttachmentsClient\AttachmentsClient::uploadFromFile(string $filename) string AttachmentsClient\AttachmentsClient::uploadFromFile(string $filename)
......
...@@ -68,3 +68,11 @@ echo "Download URL: $url\n"; ...@@ -68,3 +68,11 @@ echo "Download URL: $url\n";
``` ```
$ php index.php $ php index.php
``` ```
Для изображений сервер создаёт миниатюры, их URL можно получить так:
```
$thumbUrl = $client->getThumbnailUrl(
$hash, // хэш изображения, полученные от метода заливки
128 // желаемый размер миниатюры
);
```
...@@ -31,7 +31,20 @@ class AttachmentsClient { ...@@ -31,7 +31,20 @@ class AttachmentsClient {
* @return string * @return string
*/ */
public function getDownloadUrl ($hash, $name) { public function getDownloadUrl ($hash, $name) {
return $this->baseUrl . '/dl/' . $hash . '/' . $name; return "$this->baseUrl/dl/$hash/$name";
}
/**
* Возвращает URL для миниатюры (thumbnail) изображения.
*
* @param string $hash Хэш файла, полученный от метода загрузки.
* @param int $size (необязательно) Размер миниатюры в пикселях, по
* умолчанию - 128
*
* @return string
*/
public function getThumbnailUrl ($hash, $name) {
return "$this->baseUrl/dl/thumb/$size/$hash";
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment