I'm an getting a list of files in a folder. The response contains a iconLink
for every file returned. This icon is 16x16 pixels.
Does anyone know a way to retrieve a retina image? Or another way to retrieve a bigger icon image?
https://developers.google.com/drive/v2/reference/files
top: Google Drive UI
bottom: Google Drive API integration
The Google Drive API allows you to create apps that leverage Google Drive cloud storage. You can develop applications that integrate with Drive, and create robust functionality in your application using the Drive API.
Pricing. All use of the Drive API is available at no additional cost.
The simple answer is yes you can but it probably is not worth it. You end up having to do a lot of work yourself to implement what SQLite can offer you. And in the case of Google Drive, latency will likely be a killer.
The good news is although not officailly documented driver does have 2x resolution icons. The bad news is they have inconsistent file names; for example the icon you linked in the comments has a 32px version availabel here: ssl.gstatic.com/docs/doclist/images/mediatype/icon_3_pdf_x32.png
Now here is my soltion, it's not perfect but it will do the job for a while:
function getIcons($file_type)
{
$icons = [
'pdf' => [
'icon' => 'icon_12_pdf_list.png',
'retina' => 'icon_3_pdf_x32.png'
],
'document' => [
'icon' => 'icon_1_document_x16.png',
'retina' => 'icon_1_document_x32.png'
],
'image' => [
'icon' => 'con_1_image_x16.png',
'retina' => 'icon_1_image_x32.png'
],
'word' => [
'icon' => 'icon_1_word_x16.png',
'retina' => 'icon_1_word_x32.png'
],
'text' => [
'icon' => 'icon_1_text_x16.png',
'retina' => 'icon_1_text_x32.png'
],
'spreadsheet' => [
'icon' => 'icon_1_spreadsheet_x16.png',
'retina' => 'icon_1_spreadsheet_x32.png'
],
'form' => [
'icon' => 'icon_2_form_x16.png',
'retina' => 'icon_2_form_x32.png'
],
'audio' => [
'icon' => 'icon_1_audio_x16.png',
'retina' => 'icon_1_audio_x32.png'
]
];
return isset($icons[$file_type]) ? $icons[$file_type] : $icons['text'];
}
The reasion I say it will work for a while is that I'm asuming the _3_
in pdf icon file name for instance is the version number. So if Google updates it's icons again in the future this solution may brake.
I'm using drive rest api and what i observed was that iconLink
attribute had a definite pattern.
"https://drive-thirdparty.googleusercontent.com/" + size + mimetype
By default size is 16. So, before adding your icon to Image, use this:
String iconLink = (String) jsonObject.get("iconLink");
iconLink=iconLink.replace("16","128");
check out these both links: https://drive-thirdparty.googleusercontent.com/128/type/application/pdf https://drive-thirdparty.googleusercontent.com/16/type/application/pdf
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With