Send file to dropbox
I'm using ninox cloud.
I have a file named MyFile.pdf as an attachment on my object (size is 84 KB). I can open it in Ninox without a problem. Then I have made a button. When I click the button I want my file to be sent to my Dropbox. (I have made a multitext-field called "Response" on my current object in which i write the response for debugging purposes.)
I have the following code in my Button:
When I execute this it sends the file to dropbox and it appears in the correct folder. But when I want to open the file in dropbox it is corrupt. (When I download the file from dropbox it also can't open it and it has a size of 1 KB.)
Screenshot translated to english: "Dropbox supports .pdf-files, but something went wrong here."
Here's the dropbox API I reference: https://www.dropbox.com/developers/documentation/http/documentation#upload
Here's the ninox http-function I reference: https://docs.ninox.com/en/script/function-overview/functions/http
Can anybody help me to fix the problem?
Thanks in advance!
Tanja
P.S.: in Postman it works
17 Antworten
-
Hallo Tanja, das wird über diesen API Endpoint nicht gehen, da die Dropbox API file-content erwartet, Ninox aber keinen file-content liefert und auch nicht auf lokale Dateien zugreift. Die Dropbox API kann man aber mit dem Endpoint save_url ansprechen und dann aus der Ninox den Anhang via ShareFile anbieten...
-
Hier der Code, wie es bei mir funktioniert hat - Dank an T. Bartzsch. Der Code ist inklusive dem dynamischen FileTitle vom Dokument, welches im Bild-Feld "Rechnung" enthalten ist. Das Feld "Response" nutz ich als Debug-Info Feld -> ist nicht nötig.
-
Freut mich, dass es klappt. Das einzige Manko bei Dropbox ist der asynchrone Upload... wenn man via Schleife durch seine Dateianhänge iteriert und jedes File hochlädt, braucht es jeweils ein sleep(1000) damit er sich nicht verschluckt...
-
Häng mich mal hier dran,
bin absoluter neuling in der geschichte. Würde das im script gehen oder eher nicht? Hätte noch Make im Angebot (auch keinen schimmer davon) aber da wird es schnell Teuer. Doch die Daten müssen ausgelagert werden, sonst wird es auch Teuer.
-
Vielleicht kann mir jemand helfen, ich habe mit meinen Halbwissen versucht eine Datei in der Dropbox
abzulegen:
let url := "https://api.dropboxapi.com/2/files/save_url";
let token := "sl.Bgcps5wudyRXvN_GfK48xoJ2xLqhDMFt-cJkWKUR5Xu6lZLnofmho1oIyor2tMPe7EYBA5CyIiaQtgapsOmo6M_tVs0lywjxB5QIYrbViuPunKxhzw";
let myFileURL := shareFile(this, Datei);
let myBody := {
path: "/Ninox/" + Datei,
url: myFileURL
};
do as server
let response := http("POST", url, {
Authorization: "gwd1zqjri4lnosl " + token,
'Content-Type': "application/json"
}, myBody);
void
endAber was ist falsch? Die Variable "Datei" ist der Dateiname aus den DB-Feld.
Das Unterverzeichnis auf Dropbox heißt: Ninox
Content aside
- Status Answered
- vor 7 MonatenMon, November 4, 2024 at 2:04 PM UTCZuletzt aktiv
- 17Antworten
- 371Ansichten
-
7
Folge bereits