2013-01-16 192 views
1

我去谷歌驅動,使用鑰匙(P12)文件上傳到谷歌驅動

我可以瀏覽文件夾,獲取有關文件的數據,獲取文件列出了谷歌驅動器。但我無法將文件上傳到Google驅動器。

在所有的設置權的TEAM(爲所有者)

爲什麼不給我保存文件的可能性大嗎?

示例代碼我順利拿到文件夾列表:

def is_file_in_folder(service, folder_id, file_id): 
    try: 
    service.children().get(folderId=folder_id, childId=file_id).execute() 
    except errors.HttpError, error: 
    if error.resp.status == 404: 
     return False 
    else: 
     print 'An error occurred: %s' % error 
     raise error 
    return True 

我試圖保存文件的示例代碼:

def insert_file(service, title, description, parent_id, mime_type, filename): 
    media_body = MediaFileUpload(filename, mimetype=mime_type, resumable=True) 
    body = { 
    'title': title, 
    'description': description, 
    'mimeType': mime_type 
    } 
    if parent_id: 
    body['parents'] = [{'id': parent_id}] 

    try: 
    file = service.files().insert(body=body, media_body=media_body).execute() 

    return file 
    except errors.HttpError, error: 
    print 'An error occured: %s' % error 
    return None 

顯示錯誤 - ERROR

我承擔該文件正在嘗試加載,但有些東西阻止了他,以及(可恢復=真),他一次又一次地嘗試,直到時間。

我需要什麼才能上傳文件?

使用代碼來創建谷歌驅動器的文件夾試過,但顯示錯誤(通過身份驗證的用戶沒有必要的訪問文件)

那麼如何獲得這些權利?

+1

我會首先確定服務器迴應的實際HTTP狀態碼值,然後確定它的含義。 – martineau

+0

我在問題中描述過。 當您嘗試下載該文件顯示: 例外httplib.BadStatusLine 當您嘗試創建一個文件夾,錯誤: 的身份驗證的用戶不具有對文件 – Dmitriy

+0

對不起所需的訪問,我搞砸這一點。我只是谷歌錯誤消息文本,並得到[這](http://code.google.com/p/google-api-java-client/issues/detail?id=637)這似乎表明它可能是一個錯誤。 – martineau

回答

1

發現問題。 它出現在界面「Google Drive」上,顯示在該文件夾上的只讀對此沒有人能夠上傳文件。因此,並給出錯誤,只允許閱讀。

順便說一句,有人可以知道如何獲得文件的直接鏈接。這種格式?:http://google.com/my_file.mp3