php - 视网膜图标与 Google Drive API 的链接

标签 php google-drive-api

我正在获取文件夹中的文件列表。响应包含每个返回文件的 iconLink。这个图标是 16x16 像素。

有谁知道检索视网膜图像的方法吗?或者另一种获取更大图标图像的方法?

https://developers.google.com/drive/v2/reference/files

顶部:Google 云端硬盘用户界面

底部:Google Drive API 集成

Example

最佳答案

好消息是虽然没有正式记录的驱动程序确实有 2x 分辨率图标。坏消息是它们的文件名不一致;例如,您在评论中链接的图标在此处有一个 32 像素的版本:ssl.gstatic.com/docs/doclist/images/mediatype/icon_3_pdf_x32.png

现在这是我的解决方案,它并不完美,但它会在一段时间内完成工作:

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'];
}

我说它会工作一段时间的原因是我假设 pdf 图标文件名中的 _3_ 是版本号。因此,如果 Google 将来再次更新其图标,则此解决方案可能会失效。

关于php - 视网膜图标与 Google Drive API 的链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35781392/

相关文章:

php - php 标志 -d 是什么意思?

authentication - 如何在不要求用户复制/粘贴验证码的情况下验证 Google Drive?

javascript - 从 url 获取 pdf blob 并直接使用 puppeteer 库插入驱动器并获取

python - 如何通过python google drive api创建一个新文件夹以及MediaFileUpload的用途是什么?

php - 有一个 BaseController 并让所有 Controller 都扩展该类是个好主意吗?

php - 由当前登录的用户安全更新或插入行 'owned'

php - Laravel ajax 返回 500(内部服务器错误)

php - 从android发送数据到php,php存储一个序列?在mysql中

ruby - 使用 ruby​​ 上的 google_drive gem 在 google 电子表格中设置单元格或行背景颜色

node.js - 当我未登录 google 云端硬盘时,使用 google 云端硬盘 api 打开 google 云端硬盘文件