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

  • SEARCH
  • Home
  • 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 7867215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:39:11+00:00 2026-06-03T00:39:11+00:00

Issue #1 When i’m uploading a file to google docs i receive status code

  • 0

Issue #1

When i’m uploading a file to google docs i receive status code “201” created, but when i try to open the file it seems that i’m doing something wrong, because i can’t open it, and when i’m trying to download and open it on my PC i see the binary data instead of text or image. Current language is APEX, but i think it’s pretty understandable.

First of all i’m getting Upload URL and then putting data to this URL;

public void getUploadURL()
{
    Httprequest req = new Httprequest();
    req.setEndpoint('https://docs.google.com/feeds/upload/create-session/default/private/full?convert=false');
    req.setMethod('POST');
    req.setHeader('GData-Version', '3.0');
    req.setHeader('Authorization', 'OAuth '+accessToken);
    req.setHeader('Content-Length', '359');
    req.setHeader('X-Upload-Content-Type', fileType);
    req.setHeader('X-Upload-Content-Length', fileSize);


    Dom.Document requestDoc = new Dom.Document();

    String xml =
            '<?xml version=\'1.0\' encoding=\'UTF-8\'?>'
            +'<entry xmlns="http://www.w3.org/2005/Atom" xmlns:docs="http://schemas.google.com/docs/2007">'
            +'<title>'+fileName+'</title></entry>';

    requestDoc.load(xml);
    req.setBodyDocument(requestDoc);
    Http h = new Http();
    Httpresponse res = h.send(req);
    System.debug('response=\n'+res.getHeader('Location'));
    uploadFIle(res.getHeader('Location'));
}

public void uploadFIle(String uploadUrl)
{
    Httprequest req = new Httprequest();
    req.setEndpoint(uploadUrl);
    req.setMethod('PUT');
    req.setHeader('GData-Version', '3.0');
    req.setHeader('Authorization', 'OAuth '+accessToken);
    req.setHeader('Host', 'docs.google.com'); 
    req.setHeader('Content-Length', fileSize);
    req.setHeader('Content-Type', fileType);
    req.setBody(''+binaryData);
    Http h = new Http();
    Httpresponse res = h.send(req);
    System.debug('response=\n'+res.getBody());
}

As for “binaryData” property – i receive it from the page using javascript like this:

<input type="file" id="myuploadfield" onchange="getBinary()"/>
    <script>
        function getBinary()
        {
            var file = document.getElementById('myuploadfield').files[0];
            fileSizeToController.val(file.size.toString());
            fileNameToController.val(file.name.toString());
            fileTypeToController.val(file.type.toString());
            var r = new FileReader();
            r.onload = function(){ binaryToController.val(r.result); };
            r.readAsBinaryString(file);
        }
    </script>

r.onload = function(){ binaryToController.val(r.result); }; – this is the string that sends file binary data to my controller.

Issue #2

I’m trying to move one collection(folder) to another, and using this article (protocol tab instead of .NET). The issue is that i need to move collection instead of copying it and when i add my collection to another using this article, i’m currently adding reference to my collection instead of moving the whole collection from one place to another.

Please tell me what am i doing wrong.

Thank you for consideration.

  • 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-03T00:39:13+00:00Added an answer on June 3, 2026 at 12:39 am

    Your “binary” data is being corrupted, when you are performing '' + binaryData.

    In general, I have had more success using slicing of files, here is an example for webkit:

    var chunk = this.file.webkitSlice(startByte, startByte + chunkSize, file_type);
    // Upload the chunk
    uploadChunk(startByte, chunk, callback);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Issue In the below code , say if i want to change the color
Issue comes up when i try to unload plugin that is loaded and load
Some issue arise when sourcing one of your env file (a series of variable
This issue is somewhat related: Problem with Code Generated by XSD.EXE: Sequence of Elements
Issue with StringBuilder I have used the table tag in sb.append but it is
ISSUE: code that worked to close and destroy a cfwindow after form submit -
Issue: After uploading a SSRS 2008 R2 RDL to SharePoint 2010, a listing of
Issue I have an aspx page with jQuery code to send an ajax request
Issue Seems like the condition gets ignored. Here is my scenario: Source class public
The issue: sometimes, but not every time, Git deletes the static directory of a

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.