Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
I
ipfs-images-php-client
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ipfs-images
ipfs-images-php-client
Commits
29b76961
Commit
29b76961
authored
Sep 12, 2017
by
Dmitry Nikulin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch to streams for file uploading
parent
7c8655c7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
5 deletions
+8
-5
AttachmentsClient.php
src/AttachmentsClient.php
+8
-5
No files found.
src/AttachmentsClient.php
View file @
29b76961
...
...
@@ -25,7 +25,7 @@ class AttachmentsClient {
/**
* Загружает файл с диска на сервер (по имени файла).
* Возвращает ссылку на загрузку файла (с учётом baseUrl,
* переданного в конструктор)
* переданного в конструктор)
.
* При ошибках выбрасывается исключение.
*
* @param string $filename Путь к файлу
...
...
@@ -33,17 +33,20 @@ class AttachmentsClient {
* @return string
*/
public
function
uploadFromFile
(
$filename
)
{
$data
=
file_get_contents
(
$filename
);
return
$this
->
uploadFromMemory
(
$data
,
basename
(
$filename
));
$stream
=
fopen
(
$filename
,
'rb'
);
if
(
!
$stream
)
{
throw
new
Exception
(
"Failed to open
$filename
"
);
}
return
$this
->
uploadFromMemory
(
$stream
,
basename
(
$filename
));
}
/**
* Загружает файл из памяти на сервер.
* Возвращает ссылку на загрузку файла (с учётом baseUrl,
* переданного в конструктор)
* переданного в конструктор)
.
* При ошибках выбрасывается исключение.
*
* @param
string $data Данные для загрузки
* @param
mixed $data Данные для загрузки - строка (string) или поток (stream)
* @param string $name (необязательно) Имя файла, по умолчанию - file
*
* @return string
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment