Add Attachment support
This commit is contained in:
parent
a2c44392b2
commit
aef0c2166e
@ -29,16 +29,19 @@ class Client{
|
||||
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
|
||||
if($type!='GET'){
|
||||
if($type!='GET' && $type!='FORM'){
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
|
||||
}
|
||||
|
||||
if (!is_null($postFields)) {
|
||||
$postFields = json_encode($postFields);
|
||||
if(!is_null($postFields)) {
|
||||
if($type=='FORM'){
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: multipart/form-data']);
|
||||
}else{
|
||||
$postFields = json_encode($postFields);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json',
|
||||
'Content-Length: '.strlen($postFields), ]);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json',
|
||||
'Content-Length: '.strlen($postFields), ]);
|
||||
}
|
||||
if($this->user) {
|
||||
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||
|
@ -89,4 +89,11 @@ class Repo{
|
||||
return new Issue($this,$data);
|
||||
}
|
||||
|
||||
public function addAttachment($path,$type='image/png'){
|
||||
$url="repos/{$this->user}/{$this->repo}/releases/1/assets?name=test";
|
||||
$args=['attachment'=>new \CurlFile($path, $type, 'filename.png')];
|
||||
$data=$this->client->request($url,'FORM',$args);
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user