Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9140763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:33:31+00:00 2026-06-17T09:33:31+00:00

I am developing GAE java app and i need to upload PDF file into

  • 0

I am developing GAE java app and i need to upload PDF file into user’s google drive, but upload always fails and i don`t know what could be wrong as i checked few code samples already.

import com.google.api.services.drive.Drive;
import com.google.api.services.drive.model.File;

.
.
.

byte[] pdfContent = <... 52kb PDF file ...>


ByteArrayContent mediaContent = new ByteArrayContent("application/pdf", pdfContent);

  File myPDF = new File();
       myPDF.setTitle("Sample PDF");
       myPDF.setDescription("Sample PDF");

  Drive driveService = new Drive.Builder(HTTP_TRANSPORT, JSON_FACTORY, getStoredCredential()).build();
  Drive.Files.Insert insert = driveService.files().insert(hugePDF, mediaContent);

insert.getMediaHttpUploader().setChunkSize(1024 * 1024);
File file = insert.execute();

This upload code always gets Error: 400 OK

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "badRequest",
    "message": "Bad Request"
   }
  ],
  "code": 400,
  "message": "Bad Request"
 }
}

I am using Google drive library : google-api-services-drive-v2-rev1-1.7.2-beta.jar

Credentials are fine as i am able to list or download files from user`s google drive.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:33:32+00:00Added an answer on June 17, 2026 at 9:33 am

    I think that the problem is in your library version. Current version is v2-rev39-1.12.0-beta. Check http://code.google.com/p/google-api-java-client/wiki/APIs#Drive_API. It is always better to use last API library version. We had a lot of problems with BigQuery API when we missed one update.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing an Twitter4J web application in Google App Engine/Java. I need to
I'm developing an application on GAE (google app engine). This app is a chat
I am developing a web app on google app engine using java.I have links
I am developing a web application on Google App Engine for Java... In this
Right now i am developing an application using Google App Engine (GAE). GAE doesnt
I am developing an app for GAE. Having installed the feedparser module with setuptools,
When researching Google App Engine (GAE), it's clear that using Django is wildly popular
I'm developing on the Google App Engine and I would like to integrate Facebook
I've started using Eclipe+PyDev as an environment for developing my first app for Google
After a few months developing in GAE using google's standalone server (dev_appserver) and Aptana

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.