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.

  • Is www.yyy.com under your control? – sfdcfox Mar 13 '14 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 Mar 13 '14 at 5:17
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.

  • 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 Mar 14 '14 at 9:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.