Add Attachment support
This commit is contained in:
parent
a2c44392b2
commit
aef0c2166e
@ -29,17 +29,20 @@ class Client{
|
|||||||
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
|
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
|
||||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||||
|
|
||||||
if($type!='GET'){
|
if($type!='GET' && $type!='FORM'){
|
||||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $type);
|
||||||
}
|
}
|
||||||
|
if(!is_null($postFields)) {
|
||||||
if (!is_null($postFields)) {
|
if($type=='FORM'){
|
||||||
|
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: multipart/form-data']);
|
||||||
|
}else{
|
||||||
$postFields = json_encode($postFields);
|
$postFields = json_encode($postFields);
|
||||||
curl_setopt($ch, CURLOPT_POST, true);
|
|
||||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
|
|
||||||
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json',
|
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json',
|
||||||
'Content-Length: '.strlen($postFields), ]);
|
'Content-Length: '.strlen($postFields), ]);
|
||||||
}
|
}
|
||||||
|
curl_setopt($ch, CURLOPT_POST, true);
|
||||||
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
|
||||||
|
}
|
||||||
if($this->user) {
|
if($this->user) {
|
||||||
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||||
curl_setopt($ch, CURLOPT_USERPWD, $this->user.':'.$this->pass);
|
curl_setopt($ch, CURLOPT_USERPWD, $this->user.':'.$this->pass);
|
||||||
|
@ -89,4 +89,11 @@ class Repo{
|
|||||||
return new Issue($this,$data);
|
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