{"action":"created","issue":{"url":"https://api.github.com/repos/line/line-bot-sdk-php/issues/23","repository_url":"https://api.github.com/repos/line/line-bot-sdk-php","labels_url":"https://api.github.com/repos/line/line-bot-sdk-php/issues/23/labels{/name}","comments_url":"https://api.github.com/repos/line/line-bot-sdk-php/issues/23/comments","events_url":"https://api.github.com/repos/line/line-bot-sdk-php/issues/23/events","html_url":"https://github.com/line/line-bot-sdk-php/issues/23","id":182484999,"number":23,"title":"Determining extension of message content","user":{"login":"samwierema","id":276453,"avatar_url":"https://avatars.githubusercontent.com/u/276453?v=3","gravatar_id":"","url":"https://api.github.com/users/samwierema","html_url":"https://github.com/samwierema","followers_url":"https://api.github.com/users/samwierema/followers","following_url":"https://api.github.com/users/samwierema/following{/other_user}","gists_url":"https://api.github.com/users/samwierema/gists{/gist_id}","starred_url":"https://api.github.com/users/samwierema/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samwierema/subscriptions","organizations_url":"https://api.github.com/users/samwierema/orgs","repos_url":"https://api.github.com/users/samwierema/repos","events_url":"https://api.github.com/users/samwierema/events{/privacy}","received_events_url":"https://api.github.com/users/samwierema/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-10-12T10:03:04Z","updated_at":"2016-10-14T11:41:38Z","closed_at":null,"body":"When retrieving the content of a message (e.g. an image) it can not be determined, using the SDK, whether the image (or any other content) is of a given mime type (e.g. `image/jpeg`, `image/png`). This makes it hard to actually write the file to disk with the right extension. \r\n\r\nHere's some example code that shows the issue:\r\n```php\r\n// $message is an instance of ImageMessage\r\n\r\n$line = new LINEBot(new CurlHTTPClient('<token>'), [\r\n    'channelSecret' => '<secret>'\r\n]);\r\n\r\n$response = $line->getMessageContent($message->getMessageId());\r\nif ($response->isSucceeded()) {\r\n    // I can get the binary body with $response->getRawBody()\r\n    // but I can't get the mime type, nor the extension.\r\n    $filePath = tmpfile() . '<extension?>';\r\n    file_put_contents($filePath, $response->getRawBody());\r\n}\r\n```\r\n\r\nThere's various solutions to the issue:\r\n- I can create my own `HTTPClient` with a `getMimeType()` method, but since it's a private member of the `LINEBot` class, I can't access this in the code.\r\n- In addition to the above I can overwrite the `Response` class, but that just seems to much overwriting already. \r\n- Do the above, but in this repository\r\n- Get the extension and/or from the `ImageMessage` class (if sent back from the API)\r\n\r\nIn the `KitchenSink` example all images are written as `.jpeg` so it could be that all images are actually JPEG's, but that is not documented. \r\n\r\nCould someone provide some guidance to the above? I can make a pull request based on suggestion and/or feedback, but looking to see what the right way to go is."},"comment":{"url":"https://api.github.com/repos/line/line-bot-sdk-php/issues/comments/253777469","html_url":"https://github.com/line/line-bot-sdk-php/issues/23#issuecomment-253777469","issue_url":"https://api.github.com/repos/line/line-bot-sdk-php/issues/23","id":253777469,"user":{"login":"moznion","id":1422834,"avatar_url":"https://avatars.githubusercontent.com/u/1422834?v=3","gravatar_id":"","url":"https://api.github.com/users/moznion","html_url":"https://github.com/moznion","followers_url":"https://api.github.com/users/moznion/followers","following_url":"https://api.github.com/users/moznion/following{/other_user}","gists_url":"https://api.github.com/users/moznion/gists{/gist_id}","starred_url":"https://api.github.com/users/moznion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moznion/subscriptions","organizations_url":"https://api.github.com/users/moznion/orgs","repos_url":"https://api.github.com/users/moznion/repos","events_url":"https://api.github.com/users/moznion/events{/privacy}","received_events_url":"https://api.github.com/users/moznion/received_events","type":"User","site_admin":false},"created_at":"2016-10-14T11:41:38Z","updated_at":"2016-10-14T11:41:38Z","body":"I copy."}}
{"actor":{"display_login":"moznion"}}