-
Notifications
You must be signed in to change notification settings - Fork 119
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
Issue with attachments. #15
Comments
$client = new Client();
$client->setHttpClient(new HttpClient());
$client->authenticate(self::API_KEY, self::TOKEN, Client::AUTH_URL_CLIENT_ID);
$client->cards()->attachments()->create($id, ['file' => $name, 'name' => basename($name)]); and class HttpClient extends \Trello\HttpClient\HttpClient
{
protected function createRequest($httpMethod, $path, $body = null, array $headers = array(), array $options = array())
{
$path = $this->options['api_version'].'/'.$path;
if ($httpMethod === 'GET' && $body) {
$path .= (false === strpos($path, '?') ? '?' : '&');
$path .= utf8_encode(http_build_query($body, '', '&'));
}
$request = $this->client->createRequest(
$httpMethod,
$path,
array_merge($this->headers, $headers),
$body,
$options
);
if ( isset($body['file']) )
{
$request = $request->addPostFiles(array('file' => $body["file"]));
}
return $request;
}
} |
Thank you @xsen ! For those who are using using Laravel Trello, this also functions with the facade 😄 .
|
What is |
@molerat619 $name is file full path |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can you show me please how can an attachment can be added?
Here is my current code:
$reply_upload = $client->api('cards')->attachments()->create($id_card, array(
'file' => DOCROOT.'media/uploads/issue_tracker/'.$options['filename'],
'mimeType' => File::mime_by_ext($ext),
'name' => uniqid().'.'.$ext
));
The issue is that if I put the path to the file on the file parameter .. it shows in the content of the Trello attachment but if I use file_get_contents on it, it is ok there but the mime is not set at all.
Thanks!
The text was updated successfully, but these errors were encountered: