Google Documents List Data API アップロード編

無変換で Google Document にファイルをアップロードするためには, ResumableUploader を使います。 file はファイルへのフルパスになります。

ClientLoginAuthenticator^ cla = gcnew ClientLoginAuthenticator(
    "App",
    ServiceNames::Documents,
    email,
    password
);
ResumableUploader^ ru = gcnew ResumableUploader();
Document^ entry = gcnew Document();
entry->Title = "タイトル";
entry->MediaSource = gcnew MediaFileSource(file, "application/octet-stream");
Uri^ createUploadUrl = gcnew Uri("https://docs.google.com/feeds/upload/create-session/default/private/full/?convert=false");
AtomLink^ link = gcnew AtomLink(createUploadUrl->AbsoluteUri);
link->Rel = ResumableUploader::CreateMediaRelation;
entry->DocumentEntry->Links->Add(link);
ru->InsertAsync(cla, entry->DocumentEntry, gcnew Object);

コメント

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です