狐狸.fox 2017-08-31 02:51 采纳率: 0%
浏览 191

从Google云端硬盘获取FILE_ID?

I need, the most simple way to get some sort of object with a list of the FILE_ID's! I do not need a way to automatically grab the unique folder identifier, as I will do that manually. Please, keep it as simple as possible. Here's what I have so far:

    var fileID = ["uniquefileid","uniquefileid"];
    var folderID = "uniquefileid";
   document.getElementById("test2").innerHTML = "<iframe style='position:static; margin-top: -12px; margin-left: -1340px' src='https://drive.google.com/file/d/"+folderID+"_"+fileID[0]+"/preview' width='3480' height='1550' frameborder='0' scrolling='no'></iframe>";

Essentially, uniquefileid is replaced with a number (I don't want to share for obvious reasons), and the folderID will never change.

It seems I also can't $.get() from google either using ajax.Thank's for anyone who can guide me in the right direction.

  • 写回答

1条回答 默认 最新

  • weixin_33724059 2017-08-31 07:06
    关注

    Use files.list, and filter the response to return only fileIds. Here's the main important part from JS quickstart:

    function listFiles() {
            gapi.client.drive.files.list({
              'pageSize': 10,
              'fields': "*"
            }).then(function(response) {
              appendPre('Files:');
              var files = response.result.files;
              console.log(response.result.files);
    
              if (files && files.length > 0) {
                for (var i = 0; i < files.length; i++) {
                  var file = files[i];
                  appendPre(file.id);
                }
              }
            });
          }
    

    And sure enough it returns a list of IDs.

    Output:

    List of File Ids:
    
    1OSZ4e-bHqhagfafdszbhQv_Kn_krjODZYy-S5qy9A
    0Bzxcxgk4zccNwI7ekpFbVRzT0pkTkk
    0Bxcxzgk4zccNwI7fnpqZnlCcWVwYjQyOUk4Z0VLTdfdfM1JrNjBDNENqRVc0QWs
    1cctxcghUdfdlIEL_59hTlJjmSMgvSUKbLpiuJSauoo
    1vGx-GEXkrdfdfE0_ynO8Jx2q4BhvQNOImHWzM9CU
    1xcxzfjRjdfdfmB3ksuJ0iA4r0KO4GqYrn5ctjr7A
    0Bzgk4zccNwI7LXNOQ0xlVU5jTk0
    0Bzgk4zccNwIdfdfUWGZXdXc
    0Bzgk4zccNwdfdfUpGdmlmVVE
    1uDIeJCk4dfdf0S8v82E6h3RhH754
    
    评论

报告相同问题?