We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
hayk
8 years agoExplorer | Level 4
The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*'
Hey guys I am using npm package to work with dropbox. However when I try to upload a file I get the following error XMLHttpRequest cannot load https://content.dropboxapi.com/2/files/upload. Respo...
- 8 years ago
I used an example Meteor app, and in server/main.js I just used the node library normally:
var Dropbox = require('dropbox');
const dbx = new Dropbox({accessToken: "<ACCESS_TOKEN>"}) dbx.filesUpload({path: "/test_207235.txt", contents: "some test data"}) .then(function (response) { console.log(response) }) .catch(function (error) { console.error(error) })
That uploaded the file successfully. Attempting the same in client/main.js failed with the same error you got.
I don't have a more advanced sample available though. The filesUpload method takes a string or buffer, but beyond that I'm afraid I can't offer much insight as to how to manage files/data in node and Meteor themselves.
If you want to upload directly from the user's browser, you can use the JavaScript SDK in the browser's JavaScript. E.g., include the library via a script tag in your HTML, and run JavaScript from a script tag, as shown in the basic browser example.
hayk
Explorer | Level 4
Hi Greg!
Thanks for your reply and you got it all right!
Would you mind if I ask how you used the sdk in the server?
You see at first I tried using it in the server however I got problems passing the file object to a Meteor method in the server. Then I convereted the file to base64 send it to the server and was able to upload to dropbox, however the image was empty. So I thought the problem may be while passing file from client to server thus it would be better to directly upload to dropbox from the client. And then I got this headers' error. But I am pretty much sure I am overcomplicating something and there is a simpler solution.
Greg-DB
8 years agoDropbox Staff
I used an example Meteor app, and in server/main.js I just used the node library normally:
var Dropbox = require('dropbox');
const dbx = new Dropbox({accessToken: "<ACCESS_TOKEN>"}) dbx.filesUpload({path: "/test_207235.txt", contents: "some test data"}) .then(function (response) { console.log(response) }) .catch(function (error) { console.error(error) })
That uploaded the file successfully. Attempting the same in client/main.js failed with the same error you got.
I don't have a more advanced sample available though. The filesUpload method takes a string or buffer, but beyond that I'm afraid I can't offer much insight as to how to manage files/data in node and Meteor themselves.
If you want to upload directly from the user's browser, you can use the JavaScript SDK in the browser's JavaScript. E.g., include the library via a script tag in your HTML, and run JavaScript from a script tag, as shown in the basic browser example.
- hayk8 years agoExplorer | Level 4
Hi dear Greg,
I found the way to upload my file. The problem was in the way I was creating the buffer. So now I am able to upload from my server. I'm putting a gist here in case anyone will need it.
https://gist.github.com/hayk94/2a11702a3476f49bd65e36e7fa715d90
Though now I need to get a link of the image to show it in my HTML and there seems to be no way to do that programmatically, but I think that is another story therefore I created a new topic https://www.dropboxforum.com/t5/API-support/Share-and-get-the-link-via-api/m-p/208116#M10220
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,877 PostsLatest Activity: 3 hours agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!