Need to see if your shared folder is taking up space on your dropbox 👨💻? Find out how to check here.
Forum Discussion
arwa1
8 years agoExplorer | Level 3
upload image or file pdf to dropbox using ionic et dropbox api
var url = "https://content.dropboxapi.com/2/files/upload";
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
console.log("Uploaded a file with metadata: " + xhr.responseText);
}
};
xhr.open("POST", url, true);
xhr.setRequestHeader("Authorization", "Bearer " + this.accessToken);
xhr.setRequestHeader("Content-type", "application/octet-stream");
xhr.setRequestHeader("Dropbox-API-Arg", JSON.stringify({ "path" : "photo.jpg"}));
xhr.send();
}
erreur dans console dropbox
Failed to load resource: the server responded with a status of 415 ()
1 Reply
- Greg-DB8 years ago
Dropbox Community Moderator
Est-ce le code exact que vous utilisez? Je viens d'essayer, et il n'a pas produit d'erreur 415 pour moi.
Je recommande d'inspecter si possible la requête réseau réelle, par exemple en utilisant l'inspecteur de réseau dans les outils de développement de votre navigateur, dans le cas où le 415 était en réalité destiné à une autre requête. (Je ne peux cependant pas prendre en charge Ionic, et je n'ai pas essayé cela avec Ionic. Il est donc possible que quelque chose dans votre environnement ionique soit à l'origine du problème.)
De plus, "photo.jpg" n'est pas un chemin de fichier valide. Il devrait commencer par "/". Ainsi, par exemple, quelque chose comme "/photo.jpg".
-----------–
Veuillez nous excuser pour les traductions proposées. Ces réponses ont été générées par un outil de traduction en ligne. Nous aimerions pouvoir prendre en charge toutes les langues, mais nous ne sommes actuellement pas équipés pour y parvenir. Voici la version anglaise:
-----------–
Please excuse our translations. Our responses were created using an online translator. We'd like to support every language, but we're not currently equipped to do so. Here is the English version:
-----------–Is that the exact code you're running? I just tried it, and it didn't produce a 415 error for me.
I recommend inspecting the actual network request if possible, e.g., using the Network inspector in your browser's developer tools, in case the 415 was actually for a different request. (I can't provide support for Ionic though, nor did I try this in Ionic, so it's possible something in your Ionic environment is causing the issue.)
Also, "photo.jpg" isn't a valid file path. It should start with a "/"., so, e.g., something like "/photo.jpg".
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If 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, Facebook or Instagram.
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!