邁向慵懶人生

如何使用Google Drive當作Media Library?

Google Drive 免費空間為 15GB,可當作 WordPress Media Library  (媒體庫) 儲存空間使用。

步驟如下:

updated: 2017/1/22

 

安裝外掛 Google Drive WP Media

 

https://code.google.com/apis/console/,使用Google Account登入。

 

點選 「CREATE PROJECT」建立新專案。

 

輸入專案名稱。

 

Google API 很多,在搜尋輸入 drive 篩選出 Google Drive API。

 

點選「ENABLE」。

 

點選「Create Credentials」建立使用 API 的憑證。

 

Which API are you using? Google Drive API

Where will you ce calling the API from? Web server

What data will you be accessing? Application data

Are you using Google App Engine or Google Computer Engine? No, I’m not using them

 

Service account name (自行取一個服務名稱,例如:service)

Role (角色)? Project / Editor

Key Type? P12

 

Service account 建立完成,同時private key (私鑰檔案) 下載到本機電腦,副檔名為 p12。

 

Service account key 建立完成。(ID 隱藏中)

點選「Manage service accounts」。

 

service 的兩個欄位資料,「Service account ID」、「Key ID」後面將提供給 Google Drive WP Media 設定使用。

最後一個設定是「Private Key Url Path」。

將 private key (私鑰檔案) 上傳至 Google Drive,設定存取權限,讓 Google Drive WP Media 可遠端取用,這樣才有辦法上傳檔案至 Google Drive。

右鍵點選該私鑰檔案 (副檔名為 p12),點選「Share…」。

 

點選右下角「Advanced」。

 

點選「Change…」。

 

選擇「On – Anyone with the link」、「Access: Anyone (no sign-in required) Can view」。

 

再次,右鍵點選該私鑰檔案 (副檔名為 p12),點選「Get shareable link」。

 

複製 https://drive.google.com/…..整行。

 

 

修改為 direct access URL,須提供給 Google Drive WP Media 存取使用。

例如:複製下來的是這一行:

https://drive.google.com/open?id=0B_jxx-6fb2d261adc06dea6022f6

 

要改為這樣:

https://drive.google.com/uc?id=0B_jxx-6fb2d261adc06dea6022f6&export=download

 

Google Drive API部分準備完成,最後要設定 Google Drive WP Media 了。

 

點選「媒體」>「Google Drive WP Media」

 

Warning: 這個 plugin 需要 Google API key,前面步驟已經完成,點選 OK 略過。

 

開始設定:

Google Email: 輸入你的 Gmail

Client ID: (前面有)

Service Account Name: (前面有)

Private Key Url Path: (前面有)

 

按下儲存,若前面的步驟正確,就可以到下一步了。

 

設定正確,API 設定已完成。

 

取一個資料夾名稱,上傳的檔案會存放於此資料夾。

 

若設定正確,Google Drive 會發現多了一個資料夾:Shared with me by Google API (service)。

 

Totla quota: 15GB,是的,您已經有額外的免費 15GB 空間可使用。

 

有兩個選項建議設定:

點選「Options」。

 

啟用「Auto Create Thumbnails (自動建立縮圖)」。

 

啟用「Google Drive as Drfault Media Uoload Storage (將 Google Drive 當作媒體庫預設上傳空間)」。

 

上傳一張圖片測試看看,成功囉。

Exit mobile version