Android 台灣中文網

標題: Google Drive API 上傳權限問題? [打印本頁]

作者: 王進平    時間: 2015-12-4 11:03
標題: Google Drive API 上傳權限問題?
我最近再嘗試上傳SQLite 到雲端的功能

但遇到了一些問題

我使用[url= https://developers.google.com/drive/web/quickstart/android] https://developers.google.com/drive/web/quickstart/android[/url]

這網頁所提供的程式碼

執行後沒有問題 就是顯示10筆該帳號最近上傳的Titel和ID

然後我參考 http://anything0951.blogspot.tw/2013/07/eclipse-java-google-drive-api.html

針對程式做了一些修改

我在原本程式內的getDataFromApi()函式裡面加上了

            SQLite_ SQL=new SQLite_(Two_Sec_Billing_GoogleDrive_API.this);
            File body = new File();
            body.setTitle("My document");
            body.setDescription("A test document");
            body.setMimeType("application/x-sqlite3");

            java.io.File fileContent = new java.io.File(SQL.DB_PATH+SQL.DB_NAME);
            FileContent mediaContent = new FileContent("application/x-sqlite3", fileContent);

            System.out.println("test__1");
            File mfile = mService.files().insert(body, mediaContent).execute();
            System.out.println("File ID: " + mfile.getId());

SQL.DB_PATH =SQLite路徑

SQL.DB_NAME =SQLite名稱

這個路徑我有用來複製檔案,所以這路徑是沒有問題的

但執行到
            File mfile = mService.files().insert(body, mediaContent).execute();

會失敗

畫面顯示如附件

我翻譯後好像是缺少權限

不知道是我沒有要求權限還是我程是這樣改是錯誤的?





歡迎光臨 Android 台灣中文網 (https://apk.tw/) Powered by Discuz! X3.1