Hi
I have successfully used the dropbox component for download, upload and delete
files.
You can see my implementation below, cause there was some important issues to
solve before it worked
Actually the only problem I have is the expired_token. The generated token
(which I created in the app console) does always expire after 4 hours and then
I get the error message from the component:
InvalidAccessTokenException: {"error_summary": "expired_access_token/...",
"error": {".tag": "expired_access_token"}}
I read about other SDK which access the dropbox API, that the API does handle
to refresh the access_token if its expired.
What is my mistake? Is there a way to generate a permament access_token in
dropbox itself or how?
Here is my route for DOWNLOAD:
from("timer://simpleTimer?period=10000")
.to("dropbox://get?accessToken={{dropbox.accessToken}}"
+ "&clientIdentifier={{drobbox.clientIdentifier}}"
+ "&remotePath=/from_cellular")
.log("Dropbox download 'from Cellular': Check if there are files
available from Cellular in DropBox CellularEDI")
.choice()
.when(simple("${header:DOWNLOADED_FILES} == ''"))
.log("Dropbox download: No files available")
.when(simple("${header:DOWNLOADED_FILES} == null &&
${header:DOWNLOADED_FILE} != ''"))
.log("Dropbox download: 1 file available:
'${header:DOWNLOADED_FILE}'")
.to("file:{{dir.from.cellular}}?fileName=${header:DOWNLOADED_FILE}")
.toD("dropbox://del?accessToken={{dropbox.accessToken}}"
+ "&clientIdentifier={{drobbox.clientIdentifier}}"
+ "&remotePath=${header:DOWNLOADED_FILE}")
.when(simple("${header:DOWNLOADED_FILES} != '' &&
${header:DOWNLOADED_FILE} == null"))
.log("Dropbox download: Several files available:
'${header:DOWNLOADED_FILES}'")
.split(simple("${in.body.entrySet}"))
.setHeader("DropBoxFileName", simple("${body.getKey}"))
.setBody(simple("${body.getValue}"))
.log("Dropbox download: Save file:
${header.DropBoxFileName}")
.to("file:{{dir.from.cellular}}?fileName=${header.DropBoxFileName}")
.toD("dropbox://del?accessToken={{dropbox.accessToken}}"
+ "&clientIdentifier={{drobbox.clientIdentifier}}"
+ "&remotePath=${header.DropBoxFileName}");
Here is my route for UPLOAD:
from("file:{{dir.to.cellular}}?preMove=.inprogress&move=.done&delay=1000")
.log("Dropbox upoad: Trying to upload file ${file:name} to DropBox
CellularEDI")
.setHeader(DropboxConstants.HEADER_PUT_FILE_NAME, simple("${file:name}"))
.to("dropbox://put?accessToken={{dropbox.accessToken}}"
+ "&clientIdentifier={{drobbox.clientIdentifier}}"
+ "&uploadMode=force"
+ "&remotePath=/to_cellular/")
// The upload does not work if I don't put the last '/'
.choice()
.when(simple("${body} == 'OK'"))
.log("Dropbox upload success: File ${file:name} was uploaded to
DropBox folder: ${header:UPLOADED_FILE}")
.otherwise()
.log("Dropbox upload FAILED: File ${file:name} Failed with result:
${body}");
Environment:
Camel 3.16.0
SpringBoot 2.6.4
Java 11
Reto