2

I am stuck in my visualforce page where I am including script provide by google to achieve a Save button which below:

<script src="https://apis.google.com/js/platform.js"></script>
<div class="g-savetodrive"
   data-src="https://www.yyy.com/file/path/abc.txt"
   data-filename="My Statement.pdf"
   data-sitename="My Company Name">
</div> 

My Problem is this. When I am providing the url in "data-src" tag and click on button then my file is not upload in my drive I am getting "XHR error" because of different origin because my page loaded at https://www.xxx.com URL and the URL which I am providing in "data-src" is "https://www.yyy.com/file/path/abc.txt". I am assuming this problem is due to different origin.

Google has also provided some steps like put value in header like Access-Control-Allow-Origin: *

https://developers.google.com/drive/web/savetodrive#cors

But I don't know how can I achieve this.

2
  • Is www.yyy.com under your control?
    – sfdcfox
    Commented Mar 13, 2014 at 1:08
  • Yes www.yyy.com URL is provided by me. The actually url is "https://c.{!serverURL}.content.force.com/servlet/servlet.ImageServer?id={!reportDocumentId}&oid={!orgId} " Actually www.yy.com url is url of document file in salesforce. My requirement is when user click on button then in my function (apex) created a document file.Then I embed the above URL "data-src" resource. And then user can save that file(which in document) in google drive also.
    – D-Horse
    Commented Mar 13, 2014 at 5:17

1 Answer 1

1

You won't be able to use this library, since neither side of this attempt are under your control (i.e. you cannot change the server's operating parameters to allow these requests). Instead, you'll have to use either the Salesforce AJAX Proxy, or call the API calls from the server itself via Apex Code.

1
  • If I am not wrong your mean is I am not able to user above script which is provide by google and which I've mention in my question.
    – D-Horse
    Commented Mar 14, 2014 at 9:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .