Dropbox: put/get files (no sync)?

397 views
Skip to first unread message

Andi

unread,
Apr 3, 2014, 2:07:08 AM4/3/14
to tas...@googlegroups.com
Hi folks,

I'd like to put / get  a file to / from a non-public folder in my dropbox.

Currently, I'm using Dropsync for this task, but it is not reliable because it works in the background while my Tasker skript continues and I have no direct means to check from within Tasker if syncing has finished. At the moment, I have a loop that checks for local file change every 5 seconds for 60s total, but this is too pedestrian and fails if sync takes longer or if internet connection drops.

Is there a plugin or direct way to achieve this?

What about http_put / http_get built-in functions? Can they be applied to non-public dropbox files by utilizing Dropbox app secret?

I already found an interesting bash script based on curl and Dropbox app secret: https://github.com/andreafabrizi/Dropbox-Uploader/blob/master/dropbox_uploader.sh

It should be possible to adapt this for Tasker / Android, but maybe there is a ready solution already...

Anyone?



Background:
Using Simpletask Cloudless, I need this mechanism to sync / merge my todo.txt file, i.e.:

1.) Download dropbox todo.txt / check for change
2.) Merge with local changes in todo.txt file
3.) Upload merged todo.txt

Cheers, Andi

Pent

unread,
Apr 3, 2014, 2:36:59 AM4/3/14
to tas...@googlegroups.com

Currently, I'm using Dropsync for this task, but it is not reliable because it works in the background while my Tasker skript continues and I have no direct means to check from within Tasker if syncing has finished.

You could write to them and ask them to implement the extra tiny little bit of plugin coding that lets Tasker wait for their plugin to finish.

The dev link is:

http://tasker.dinglisch.net/plugins.html#synch

Pent

Brandon Horwath

unread,
Apr 3, 2014, 12:40:53 PM4/3/14
to tas...@googlegroups.com
Here is how I use http get to check my dropsync success...

First, I check if I can connect to Dropbox. Then I check and confirm the upload success.

Work Log Completion (317)
A1: Profile Status [ Name:Cell Tower Change Set:Off ]
A2: Profile Status [ Name:APP Log Monitor Set:Off ]
A3: Profile Status [ Name:SCREEN Log Monitor Set:Off ]
A4: Profile Status [ Name:CALL Log Monitor Set:Off ]
A5: Profile Status [ Name:TEXT Log Monitor Set:Off ]
A6: Write File [ File:%Work_log Text:End Work Log at %TIME Append:On Add Newline:On ]
A7: Say [ Text:Work Log Monitor Closed Engine:Voice:default:default Stream:5 Pitch:5 Speed:5 Respect Audio Focus:Off Continue Task Immediately:Off ] If [ %SILENT ~ off ]
A8: HTTP Get [ Server:Port:<username>:<password>@www.dropbox.com Path:/m/home?path=/Documents/Documents/Business%20Documents/Work%20Logs/Work Attributes: Cookies: Timeout:15 Mime Type: Output File: ]
A9: If [ %HTTPR ~ 302 ]
A10: Say [ Text:Connected Engine:Voice:default:default Stream:5 Pitch:%Voice_Pitch Speed:%Voice_Speed Respect Audio Focus:Off Continue Task Immediately:On ] If [ %SILENT ~ off ]
A11: Flash [ Text:%Work_log uploading to DropBox Long:Off ]
A12: Dropsync [ Configuration:Sync Now Package:com.ttxapps.dropsync Name:Dropsync Timeout (Seconds):0 ]
A13: Wait [ MS:0 Seconds:1 Minutes:0 Hours:0 Days:0 ]
A14: Variable Set [ Name:%Work_log To:%Calloc-%Date.txt Do Maths:Off Append:Off ]
A15: HTTP Get [ Server:Port:<username>:<password>@www.dropbox.com Path:/m/home?path=/Documents/Documents/Business%20Documents/Work%20Logs/Work/%Work_log Attributes: Cookies: Timeout:15 Mime Type: Output File: ]
A16: If [ %HTTPR ~ 302 ]
A17: Say [ Text:%Calloc log uploaded to dropbox Engine:Voice:default:default Stream:5 Pitch:%Voice_Pitch Speed:%Voice_Speed Respect Audio Focus:Off Continue Task Immediately:Off ] If [ %SILENT ~ off ]
A18: Flash [ Text:%Calloc log uploaded to dropbox Long:Off ]
A19: Variable Clear [ Name:%Calloc Pattern Matching:Off ]
A20: Variable Clear [ Name:%Work_log Pattern Matching:Off ]
A21: Variable Clear [ Name:%Date Pattern Matching:Off ]
A22: Else
A23: Say [ Text:An error occurred Engine:Voice:default:default Stream:5 Pitch:%Voice_Pitch Speed:%Voice_Speed Respect Audio Focus:Off Continue Task Immediately:Off ] If [ %SILENT ~ off ]
A24: Flash [ Text:An error occurred Long:Off ]
A25: End If
A26: End If

Hope that helps give you an idea of what you're looking to do.

Andi

unread,
Apr 3, 2014, 1:02:56 PM4/3/14
to tas...@googlegroups.com
Hmm... looks interesting but it won't work in my case because the file name is always the same: todo.txt

Also, I don't want  to store my dropbox credentials within tasker.

But the bash script I mentioned  in my first post looks very promising indeed. I got it working after  installing curl as described here: http://forum.xda-developers.com/showthread.php?t=2362386

The script will automatically set itself up with a dedicated dropbox API key.

But it failed  to verify the dropbox SSL certificate. I have to install it manually or disable certificate validation...

Brandon Horwath

unread,
Apr 3, 2014, 1:28:01 PM4/3/14
to tas...@googlegroups.com
Hmm... looks interesting but it won't work in my case because the file name is always the same: todo.txt

That will not impact successful completion of the task, actually...

Also, I don't want to store my dropbox credentials within tasker.

It's a secure site. You'll need to provide some level of credentials in order to access and upload... going with a dedicated api key like token login is far, far, less secure. Especially, since I can almost guarantee the process is specifically used in the manner you've utilized... and sticks out like a big red flag.

Trying to narrow security for one process on one application is super easy. Trying to narrow 500 entries for specific data occurring in one random process using Tasker makes circumventing much more difficult.

But the bash script I mentioned in my first post looks very promising indeed. I got it working after installing curl as described here: http://forum.xda-developers.com/showthread.php?t=2362386

We have two very different thoughts about this. Just, FYI...

The script will automatically set itself up with a dedicated dropbox API key.

... oh joy. A third party solution. Which leads you to believe is more secure, why? Because more people were involved in creating it?

But it failed to verify the dropbox SSL certificate. I have to install it manually or disable certificate validation...

So, completely ignore automation or security... yeah, you found a winner with this one.

Well... since you're actually not looking for a way to put/get files from Dropbox using Tasker, I wish you the best.

Hope it works out for you.

Andi

unread,
Apr 3, 2014, 2:42:20 PM4/3/14
to tas...@googlegroups.com
No offense, please - I didn't mean to make your solution look bad or to disrespect your efforts.
 
Hmm... looks interesting but it won't work in my case because the file name is always the same: todo.txt

That will not impact successful completion of the task, actually...

You're right, but it won't help me to check if the file has been uploaded properly... My phone is not always-online and I want to disable internet connection as soon as dropbox sync has finished.

Also, I don't want  to store my dropbox credentials within tasker.

It's a secure site. You'll need to provide some level of credentials in order to access and upload... going with a dedicated api key like token login is far, far, less secure. Especially, since I can almost guarantee the process is specifically used in the manner you've utilized... and sticks out like a big red flag.

I not refering to SSL security, but to phone security, i.e. storing my dropbox login credentials -- which may grant full access to my dropbox account to anyone  --  within tasker versus a dedicated API key which will only grant access to a single dedicated folder in my dropbox....
 

Trying to narrow security for one process on one application is super easy. Trying to narrow 500 entries for specific data occurring in one random process using Tasker makes circumventing much more difficult.

But the bash script I mentioned  in my first post looks very promising indeed. I got it working after  installing curl as described here: http://forum.xda-developers.com/showthread.php?t=2362386

We have two very different thoughts about this. Just, FYI...

The script will automatically set itself up with a dedicated dropbox API key.

... oh joy. A third party solution. Which leads you to believe is more secure, why? Because more people were involved in creating it?

Which third party are you talking about? The makers of curl - which is a well-known unix tool - or the makers of the bash script whose contents are easily understood? I'm not afraid of both...
 

But it failed  to verify the dropbox SSL certificate. I have to install it manually or disable certificate validation...

no need to worry, curl just wasn't able to find its ca cert bundle, I modified the bash script to point curl to the right place (--cacert /system/usr/ca-bundle.crt) and now it works like a charm...

Marta Hintz

unread,
Apr 3, 2014, 2:45:11 PM4/3/14
to tas...@googlegroups.com
All is not lost however. I am picking apart the task you shared and will implement it for my needs. Thanks Brandon
Message has been deleted
Message has been deleted

Brandon Horwath

unread,
Apr 3, 2014, 5:12:17 PM4/3/14
to tas...@googlegroups.com
Glad to hear Martha!

As for workarounds for OP, I'm glad it is working for your needs.

The issue:


but it won't help me to check if the file has been uploaded properly... My phone is not always-online and I want to disable internet connection as soon as dropbox sync has finished.

... is easily addressed with certain modifications to the task.

Your security concerns are well founded, I simply don't use cloud services for secure info. So, I guess I don't have those.

Glad at least the credentials are being managed in a manner you're comfortable with, and you've had overall success.

Andi

unread,
Apr 6, 2014, 8:06:59 AM4/6/14
to tas...@googlegroups.com
I finally got rid of Dropsync and ported my sync script to dropbox_uploader.sh and if anyone is interested, here is how I did it.


To make dropbox_uploader.sh work on Android, perform the steps described at https://github.com/andreafabrizi/Dropbox-Uploader/wiki#making-it-work-on-android



My tasker sync script for syncing todo.txt from SimpleTask Cloudless with Dropbox now looks like

Sync Todo.txt New (22)
    Stay Awake
    A1: Variable Set [ Name:%local_todofile To:/storage/sdcard0/data/nl.mpcjanssen.simpletask/todo.txt Do Maths:Off Append:Off ]
    A2: Variable Set [ Name:%dbuploader To:bash /storage/sdcard0/todo/dropbox_uploader.sh Do Maths:Off Append:Off ]
    A3: Variable Set [ Name:%synced_todofile To:/storage/sdcard0/todo/todo.txt Do Maths:Off Append:Off ]
    A4: Variable Set [ Name:%remote_todofile To:todo/todo.txt Do Maths:Off Append:Off ]
    A5: Variable Set [ Name:%merged_todofile To:/storage/sdcard0/todo.merged Do Maths:Off Append:Off ]
    A6: Variable Set [ Name:%temp_todofile To:/storage/sdcard0/todo/todo.tmp Do Maths:Off Append:Off ]
    A7: Run Shell [ Command:%dbuploader download  %remote_todofile %temp_todofile Timeout (Seconds):0 Use Root:Off Store Output In:%duout Store Errors In: Store Result In:%dures Continue Task After Error:On ]
    A8: If [ %dures != 0 ]
    A9: Notify [ Title:todo.txt sync Text:Download failed: %duout Icon:null Number:0 Permanent:Off Priority:3 ]
    A10: Stop [ With Error:Off Task: ]
    A11: End If
    A12: Run Shell [ Command:cmp %local_todofile %synced_todofile Timeout (Seconds):0 Use Root:Off Store Output In: Store Errors In: Store Result In:%local_changed Continue Task After Error:On ]
    A13: Run Shell [ Command:cmp %temp_todofile %synced_todofile Timeout (Seconds):0 Use Root:Off Store Output In: Store Errors In: Store Result In:%remote_changed Continue Task After Error:On ]
    <remote changed?>
    A14: If [ %remote_changed = 1 ]
    <both changed>
    A15: If [ %local_changed = 1 ]
    A16: Run Shell [ Command:sort -u %local_todofile %temp_todofile > %merged_todofile Timeout (Seconds):0 Use Root:Off Store Output In: Store Errors In:%TODOERR Store Result In: ]
    A17: Run Shell [ Command:%dbuploader upload %merged_todofile %remote_todofile Timeout (Seconds):0 Use Root:Off Store Output In:%duout Store Errors In: Store Result In:%dures Continue Task After Error:On ]
    A18: If [ %dures != 0 ]
    A19: Notify [ Title:todo.txt sync Text:Upload failed: %duout Icon:null Number:0 Permanent:Off Priority:3 ]
    A20: Stop [ With Error:Off Task: ]
    A21: End If
    A22: Run Shell [ Command:cat %merged_todofile > %local_todofile && cat %merged_todofile > %synced_todofile && rm -f %merged_todofile Timeout (Seconds):0 Use Root:Off Store Output In: Store Errors In:%TODOERR Store Result In: ]
    A23: Notify [ Title:todo.txt sync Text:file changed locally and remotely -> merged Icon:null Number:0 Permanent:Off Priority:3 ]
    <remote changed only>
    A24: Else
    A25: Run Shell [ Command:cat %temp_todofile > %local_todofile && cat %temp_todofile > %synced_todofile Timeout (Seconds):0 Use Root:Off Store Output In: Store Errors In:%TODOERR Store Result In: ]
    A26: Notify [ Title:todo.txt sync Text:file changed remotely only -> replaced local file Icon:null Number:0 Permanent:Off Priority:3 ]
    A27: End If
    A28: Else
    <local changed only>
    A29: If [ %local_changed = 1 ]
    A30: Run Shell [ Command:%dbuploader upload %local_todofile %remote_todofile Timeout (Seconds):0 Use Root:Off Store Output In:%duout Store Errors In: Store Result In:%dures Continue Task After Error:On ]
    A31: If [ %dures != 0 ]
    A32: Notify [ Title:todo.txt sync Text:Upload failed: %duout Icon:null Number:0 Permanent:Off Priority:3 ]
    A33: Stop [ With Error:Off Task: ]
    A34: End If
    A35: Run Shell [ Command:cat %local_todofile > %synced_todofile Timeout (Seconds):0 Use Root:Off Store Output In: Store Errors In:%TODO Store Result In:%TODOR ]
    A36: Notify [ Title:todo.txt sync Text:file changed locally only -> replaced remote file Icon:null Number:0 Permanent:Off Priority:3 ]
    A37: Else
    A38: Notify [ Title:todo.txt sync Text:remote and local file unchanged, nothing to do Icon:null Number:0 Permanent:Off Priority:3 ]
    A39: End If
    A40: End If
    A41: Run Shell [ Command:rm -f %temp_todofile Timeout (Seconds):0 Use Root:Off Store Output In: Store Errors In: Store Result In: ]

Sagar Behera

unread,
Sep 6, 2014, 10:38:37 AM9/6/14
to tas...@googlegroups.com
Hi Andi! this looks awesome! 

However, my phone is not rooted. Any way in which this can work without rooting!?
Reply all
Reply to author
Forward
0 new messages