Aug 052013
 

I wanted to be able to upload photos from my RasPiCamcorder straight to DropBox. So I did a little research and came across an absolute gem of a program called Dropbox-Uploader, by Andrea Fabrizi.

A truly brilliant piece of work that gives you access to your DropBox account right from the command line.

You do have to jump through a couple of hoops to get it set up (security mostly), but once you’ve done that, it’s a breeze.

1. DropBox account

First of all you need a DropBox account. Hop on over to DropBox and get one – it’s free.

2. Download and Set Up DropBox Uploader

Next, you need to get Dropbox Uploader onto your Pi

cd ~ this ensures you are in /home/pi
git clone https://github.com/andreafabrizi/Dropbox-Uploader.git
ls

(If this fails, you may need to install git with sudo apt-get install git-core)

You should be able to see a directory called Dropbox-Uploader

cd Dropbox-Uploader
ls

You should now see three files, one of which is called dropbox_uploader.sh. This is the script we’re going to use.

DropBox-Uploader files

3. Now the fiddly bit – API keys

Run the script with ./dropbox_uploader.sh (if it fails, try chmod +x dropbox_uploader.sh)

You should see this…

Sorting out the DropBox API keys

You then need to visit this link https://www.dropbox.com/developers/apps, login to DropBox and create an “app” by clicking the “create app” button.

Then choose “Dropbox API app”, “Files and Datastores”, and answer the final question “Can your app be limited to its own, private folder?” – either answer is OK, depending on your needs.

Then you need to give your app a unique name, and you will be assigned some keys to go with the name. Now you need to type in those keys here…

Entering your app’s DropBox API keys

Once you’ve entered your keys and answered the question “app” or “full”, your Pi will request an authorisation token and you will be given a web URL you need to visit to activate it…

DropBox API authorisation

This is the part which annoyed me, as I was using a different computer to ssh into the Pi and couldn’t cut and paste the “rather tricky to type accurately” URL. But once you’ve got past that hurdle it should all just work. :)

If it works, you should see this in your browser…

Your DropBox account connected to your “app”

4. Now you can use DropBox Uploader on your Raspberry Pi…

…from the command line like this…

cd home/pi/Dropbox-Uploader
./dropbox_uploader.sh upload /home/pi/name_of_upload_file name_of_upload_file

This will upload the file you choose to your DropBox account.

…or use it in a Python script like this…

from subprocess import call
photofile = "/home/pi/Dropbox-Uploader/dropbox_uploader.sh upload /home/pi/photo00001.jpg photo00001.jpg" 
call ([photofile], shell=True)

And, if you look at the DropBox Uploader documentation, there’s a lot more commands you can make use of…

  • upload
  • download
  • delete
  • move
  • list
  • share
  • mkdir

I think this is brilliant. Yes you have to jump through a couple of hoops, but to be able to take a photo and see it on my PC, phone or Nexus 7 tablet within 30 seconds is pretty darned cool. I’ll jump through a couple of hoops for something that cool.

Here’s what it looks like in action, taking a photo and uploading to DropBox automatically. The DropBox upload photo part starts at 5m 7s.

Update April 2015 – progress bar gone :(

There is no longer a progress bar by default when you are uploading. This is a real shame. I installed dropbox uploader on a new setup and for ages I thought that it wasn’t working, when in fact it was just uploading a 30 Mb file and was taking about 10 minutes to do it on a slow connection.

I don’t know where the progress bar has gone, but it is sorely missed. I redid the “linking with dropbox” process 3 times, thinking it wasn’t working, before I thought to try a smaller file and found that it was working OK. Patience, and monitoring “top” for the curl command threw some light on things.

I’ve now found out you can put the progress bar back in if you edit the file…

nano /home/pi/Dropbox-Uploader/dropbox_uploader.sh

…and change SHOW_PROGRESSBAR=0 to SHOW_PROGRESSBAR=1

#Default values
TMP_DIR="/tmp"
DEBUG=0
QUIET=0
SHOW_PROGRESSBAR=1
SKIP_EXISTING_FILES=0
ERROR_STATUS=0

YAY! :)

  171 Responses to “How to use DropBox with Raspberry Pi”

  1. Now _that_ is a handy piece of software :-)

    • It’s brilliant isn’t it? What I love about it is that it’s basically a bash script using curl, so nothing much to install. You can call it from a Python script, and once you’ve done the initial setup it “just works”. :)

  2. You forgot to mention an easy way to manage/navigate dropbox with nice addon dropShell

    • LOL. I didn’t forget anything, I didn’t even know about it :p

      But I will delve into that further when I get the chance – it sounds interesting. Thanks for the tip. :)

  3. Hi Alex
    I got through the procedure, and got the message –

    Success! KCuploader2 is connected to your Dropbox.

    However, when I tried to upload a file called colours.jpg, it failed:

    pi@raspberrypi ~/Dropbox-Uploader $ ./dropbox_uploader.sh upload /home/pi/colours.jpg
    > Uploading “/home/pi/colours.jpg” to “/colours.jpg”… FAILED
    An error occurred requesting /upload
    pi@raspberrypi ~/Dropbox-Uploader $

    Can you see what I’m doing wrong?

    Cheers
    Kieran

    • Not unless it’s something silly like colours.jpg being in a directory other than /home/pi or internet connectivity?

      Try a different command? e.g. list.

      I haven’t played with this at all, but it would tell you if there was a general connectivity issue or a problem with the file you tried to upload.

      • hallo how can solve this
        from subprocess import call
        photofile = “/home/pi/Dropbox-Uploader/dropbox_uploader.sh upload /home/pi/2.jpg 2.jpg”
        call ([photofile], shell=True)
        when run the file in raspberry pi
        An error occurred requesting /upload
        pi@raspberrypi ~/Dropbox-Uploader $
        when upload a image to dropbox

    • Same problem. Did you resolve it?

      • Steve says: I am a mech eng and noooo expert but I just managed to load up dropbox and add files. Some points are: 1) Case sensitive; 2) I don’t think it will like the “/”. I used the command $ ./dropbox_uploader.sh /home/pi/Photos/IMG0052.JPG IMG_0052.JPG to test the ADAFRUIT PiCam BUT 3) I had to make a directory in Dropbox for Photos first. This is why I don’t think it likes the “/”. Cheers Steve

    • Same problem here, too. Will try again with it at some point, though, as this could be really useful.

    • Did you guys give dropboax uploader access to your whole dropbox or just a specific directory? I gave it access to the whole lot. Just wondering if it makes a difference?

      • Worked perfectly second time around. Looks like I did list the wrong access level when setting up the Pi. I had to delete the Dropbox app, and unlink the Pi (./dropbox_uploader.sh unlink) before I could redo the Pi setup. Thanks for a really useful tutorial.

        • So which access level was the wrong one? And which was the right one? I’ve never tried anything other than full access.

          • I think first time around I told Dropbox to give the app access to the app folder only, and then mistakenly told Dropbox Uploader that it had full access. I’ve now got it working with full access, but I’ve no reason to think that folder access wouldn’t work.

  4. This looks great to use just done the Dropbox app and installed the keys
    can you advise as I have never had the pi on the web direct what browser would you recommend. I do not use any desktop programs with it.

    Terry

    • I did the web browser bit with my laptop (hence the comment about having to retype the tricky URL). But you can use Midori as a browser if you’re patient. (It’s not the Pi’s strength – frankly it’s too darned slow for me, but web browsing is not what it’s for IMHO – I have plenty of other devices that do that well.)

      • Thanks for quick reply despite being a very old noob well I cut my teeth on Nascom and ZX81. I had saved the web link but it has timed out so start again tomorrow.
        It is easy to copy paste from PI using Putty to a Vistal Laptop.
        It took me a time to find just highlight the pi text with left mouse click and hold drag to end of the text. Do nothing more in Putty
        Open the text edit program and do a ctrl v and the pi text is pasted to your program or browser address bar

        Terry

        • Hi Terry,
          Join the club….ZX81 was my first intro to programming…1kb or a 16kb wobbly RAM pack! Is it me or was Z80 machine code a damn site easier than Linux???

          Anyway, just to add to your comments about copy/paste….
          Alex, as I assume you are copying the other way (ie copy from PC and paste to RPi) you select the text from your browser (or wherever) and CTRL C as usual then use PUTTY and just right-click. The text is pasted straight away. The other way, highlighting PUTTY text automatically copies it to the clipboard.

          Dave

  5. Hi Alex,
    Brilliant!!
    Your instructions are great! Unlike most things I’ve tried to do with the Pi, I went from reading your post to uploading a file to dropbox in about 5 minutes!!!

    Thanks again……now we just need a GUI method! ;-)

    Dave

    • Thank you Dave. That would be mission accomplished then. Clear, precise instructions that work first time is what I strive for. I don’t do GUI on pi (yet).

  6. All worked first time today thanks a lot for you time and effort.
    PI to DropBox to Laptop takes 11 seconds .

  7. Cool. Works. Give it a try :) Thank You

  8. I tried it and it works perfectly. Thanks.

    I just have one question. By any chance, does anybody know a simple way to get (and use) the information given by the instruction “list” inside my python script ?

    I would like for exemple that my python script compare the content of a dropbox (remote) folder with a local folder. I have tried to google this issue but I did not find anything I could really use.

    I have to confess that I am still a newbie with both python and RPI (but oh boy, I have so much fun ;) )

  9. Thanks, great article

  10. I have been using Dropbox with my Rpi from the beginning, but via my linux workstation and the “sshfs” command.

    On the Rpi, I use “sshfs :Dropbox Dropbox”

    Then I use the Rpi Dropbox directory as normal.

    Works like a champ.

    • How do you do this. Could you please link a more detailed explanation.
      Thanks in advance.

  11. Oh, oh!

    git clone https://github.com/andreafabrizi/Dropbox-Uploader.git

    returned:
    Cloning into ‘Dropbox-Uploader’…
    error: The requested URL returned error: 503 while accessing https:/github.com/
    andreafabrizi/Dropbox-Uploader.git/info/refs
    fatal: HTTP request failed

    pi@raspberrypi ~ $

    Problems in Andea’s directory?

    Help please.

  12. I got it working! Going to Andrea’s site took me through it. The above git clone command evidently didn’t like the …-Uploader.git at the end, wanted …-Uploader/ (no .git)

    Here is the link to her site: – good luck everybody – cool stuff!

    https://github.com/andreafabrizi/Dropbox-Uploader

  13. I seem to have linked it to the wrong a/f. Unlink didn’t seem to work for me. What’s the easiest way to uninstall the Dropbox-Uploader and start a fresh?

    Thank you, and very helpful. I had this working on another SD and it works seamlessly!

    • It’s just a bash script, so not really “installed” as such. I don’t know quite what it does with the keys and token though. The only foolproof way would be to flash a fresh SD card, but it’s probably really only a question of finding and deleting a couple of files.

      • Okay, no worries. I think it’ll be as quick to do a fresh SD ;)

        • All working. It was down to me using ‘f’ instead of ‘a’. Fresh SD did the job. I’m sure theres a quicker way, but for me it was quicker to just do a fresh install. This is part of an art exhibition in london at some point in spring next year. I’ll send some pics over to see your script on a big scale ;)

          Great work.

  14. Could I ask where the default configuration file is? I don’t see one in the location stored in the code – I have the default installation.
    Thanks for a great product,
    TIm

    • I think you’d be best off contacting the author through his GitHub account :)

    • If I understand correctly what you’re looking for the file is .dropbox_uploader (with a dot at the front) in your home directory.
      Type ls -al for a listing including any config files.
      It contains details of your APPKEY, APPSECRET, ACCESS_LEVEL, OAUTH_ACCESS_TOKEN and OAUTH_ACCESS_TOKEN_SECRET.

      • Thanks Neil – I eventually emailed the author and he kindly put me on the right track. I use DU with a couple of piCams to look at the view from my windows when traveling – very nice. It’s also good for tracking your home IP remotely without use a DDNS – very handy.

  15. Hi, Thanks for the tutorial the upload to dropbox works only manually “./dropbox_uploader.sh upload /home/pi/ocr_pi.png”
    but if i run it with the attached Python script it shows some error on line 4

    Please help ..

    Thanks.
    Nick.

  16. Hi, great tutorial.
    is there a script that takes the last created file and uploads it to Dropbox?
    not sure if i have missed something as your video does it but i can’t see any code to do this.

    this is what i have so far: –

    from subprocess import call
    import os
    import glob
    newest = max(glob.iglob(‘*.jpg’), key=os.path.getctime)

    photofile = “/home/pi/Dropbox-Uploader/dropbox_uploader.sh upload /home/pi/ newest”
    call ([photofile], shell=True)

    so as you can see i have just replaced the file name with the ‘newest’ object but it just sees it as a file name.

    Thanks,

  17. To upload any file from command line try:
    write python app:

    from subprocess import call
    import sys
    TheCall = “/home/pi/Dropbox-Uploader/dropbox_uploader.sh upload ” + sys.argv[1] + ” /DropboxDestination”
    call ([TheCall], shell=True)

    The, from the command line do something like: python dropbox.py /home/pi/test.txt

  18. I can’t get the Uploader to work. I got through the tutorial OK, but could not see the .jpg on the Dropbox. I used:
    ./dropbox_uploader.sh upload /home/pi/name_of_upload_file with my .jpg file name. All I get is Uploader help file.
    I decided to re-install the Dropbox-Uploader again, removing the old directory. I can do the git command to download the file OK. But, now I can’t run even run this script:
    ./dropbox_uploader.sh I just get the help file again.

    • I found the trouble. If I use the Andrea script without the .git at the end, replaced by a forward slash, it works.

  19. Uploader wont work. Reinstalled Dropbox-uploader and getting help file. removed .git from:
    git clone https://github.com/andreafabrizi/Dropbox-Uploader.git
    to get: git clone https://github.com/andreafabrizi/Dropbox-Uploader/ and it still goes into help menu
    Any ideas?

    • I’ve just had a look at this myself – looks like the syntax of the script has changed slightly (maybe Alex could add a note to the article above) and the ‘upload’ option now requires a destination filename in Dropbox. I.e. instead of:
      ./dropbox_uploader.sh upload /home/pi/myfile.jpg
      you now need to do:
      ./dropbox_uploader.sh upload /home/pi/myfile.jpg myfile.jpg

      • Thanks for that. Will make changes in the text. I’m still using the old version on my RasPiCamcorder.

        • I following the steps as above, but when I run Run the script with ./dropbox_uploader.sh (if it fails, try chmod +x dropbox_uploader.sh) for the first time, I do not get the option of adding my app, I just get the help menu.

          Why is that?

          Dave

      • I tried the code a couple different ways (please forgive me if I have reposted this) I have a couple questions. one: are you suppose to have a app folder inside the dropbox folder and suppose to direct the files to go into that folder? I change the destination folder to three subfolders in the same folder that the .sh is in. (i.g. /home/pi/subfolder1/subfolder2/subfolder3/tada.jpg) but when I run the code it “no such directory or file found /home/pi/……. I have a couple prematations of the order of the directories and beginning slashes and no slashes…so far it all ends with depression and failure.

        • Have you done ‘mkdir -p /home/pi/subfolder1/subfolder2/subfolder3’ ? Linux doesn’t auto-create “missing” folders for you.
          (If it’s not that, I don’t have any other suggestions as I don’t use this Dropbox script)

  20. Yup, that worked, thank you.

  21. Hi all. Brilliant solution. Thanks for the excellent guides, Alex.

    I’ve a but I can’t crack. Dropbox-uploader works great when I call it from command line, but when I try to do so within a script, I am prompted to enter the app key as if I’ve not linked the app. For some reason if I initiate the shell script while not in the Dropbox-Uploader folder, I get the same result: requesting the app key. Even tried an os.chdir in the script to get around this, thusly:

    #!/usr/bin/env python
    #picamera_test.py

    import time
    import picamera
    from subprocess import call
    import os
    import glob

    newest = max(glob.iglob(‘*.jpg’), key=os.path.getctime)

    camera = picamera.PiCamera()
    try:
    camera.start_preview()
    time.sleep(2)
    camera.capture(‘test.jpg’)
    camera.stop_preview()
    os.chdir(“/home/pi/Dropbox-Uploader”)
    photofile = “./dropbox_uploader.sh upload /home/pi/” + newest + “Code/Pi” #tried with and without specifying filename to place
    call([photofile], shell=True)
    finally:
    camera.close()

    Any help is greatly appreciated.

  22. I have a problem with the starting upload a file at boot. Could anyone help me?

  23. Hy Mr, i have problem
    while i write scrip… git clone https://github.com/andreafabrizi/Dropbox-Uploader.git
    but show // error: server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none while accessing https://github.com/andreafabrizi/Dropbox-Uploader.git/info/refs
    fatal: HTTP request failed
    i hope help you,,, thank you

  24. hello, thx for a good tutorial
    but is there a way to download whole dropbox at once win this script?

  25. Thanks for the tutorial,
    I have one small problem, every time a photo uploads to dropbox it overwrites the last photo that was sent. Any ideas on how to fix this?

    Thanks

    • Are you using the same file name for each photo? If you use a unique name for each shot, surely that won’t happen?

      • That is probably the problem, How can I change that? I am really new to working with the RasPi.

        • Without saying how you’re taking the photo, I can’t really help. If you’re using raspistill, the bit after the ‘-o’ defines the file name

          e.g. raspistill -t 500 -o /home/pi/photo.jpg

          photo.jpg should be different for each photo

  26. The pictures appear to get a unique file name when saved in the Pi folder (consecutive numbering) but after the uploader moves the file to dropbox the file name is changed to Photo. makes me think something needs to be modified in the uploader..

  27. Thanks, Alex, to your excellent tutorial, my Raspi located very far away is sending me every night on my dropbox the pics of the day. It has been working for 6 months now….GREAT.
    But the internet connection at the place where the raspi is, is not reliable and the signal drop down from time to time…I am thinking to add to your python script:
    01.from subprocess import call
    02.photofile = “/home/pi/Dropbox-Uploader/dropbox_uploader.sh upload /home/pi/photo00001.jpg photo00001.jpg”
    03.call ([photofile], shell=True)

    some sort of loop or while true

    but I don’t know really the exact syntax to apply
    Have you an idea ?

    Michel

  28. i would like to use this to up date files at multiple sites updates would be as needed upload for home and download to sites maybe once a week. Would be willing to listen to any advice please and thank you.

  29. Photos are in Photos Folder.
    /home/pi/Photos

  30. I am trying to get this to work. I have gotten it Connected (I think) but there is no app folder that pops up. Shouldn’t there be like a folder in Dropbox if things done right. I changed the syntax so I don’t get the menu but I getting a “no such file or directory exist” error. But it does… Help.

  31. I got the token error when upload my appkey & appsec.
    it told no such folder or dictionary .
    anyone who can help me with it、
    Thanks in advance!

    • Umm, what? You don’t need to ‘upload’ your appkey and secret.
      Try following the instructions again, but more carefully?

  32. im trying to upload a photo(that captured with pressing a buttun on raspberry input)to dropbox.can i use this app to my project?

  33. Hi Andrea, thanks for the great tutorial. Managed to install everything but I believe I haven’t quite understood one thing: I am using my RPi as a digital picture frame and would like to have one dropbox folder (with many subfolders) to which my family can upload pictures (in folders and directly) by using the dropbox link. Is that possible with this setup?

    • Looking at the instructions for the DropboxUploader script at https://github.com/andreafabrizi/Dropbox-Uploader I guess you’ll need to use the download option of dropbox_uploader.sh (assuming I’ve understood your question correctly) – it says it supports “File and recursive directory download”.
      You’ll probably want a bash script running in an infinite loop, which recursively downloads your selected directory, waits 15 minutes, tries recursively downloading your directory again (to see if any new photos have been added), waits another 15 minutes, etc.

      P.S. Andrea is the author of DropboxUploader, but the tutorial on this page was written by Alex :-)

      • Thanks Andrew. I get to step 4 without problems, but I have no idea how to write the script where I get one particular folder with the respective subfolders to be synched every five minutes. I guess I can put repeated execution into the crontab but how would the script have to look like? Sorry, for maybe asking very basic questions..

        • Yeah, using crontab is probably an easier / more reliable option than writing a script to run in an infinite loop. Although IMHO “every five minutes” is perhaps a little too frequent – if you have a lot of photos to download, you might end up with two instances of the download script running at once?!
          You should just be able to put something like “/home/pi/Dropbox-Uploader/dropbox_uploader.sh download photos/shared /home/pi/dropbox-photos” into your crontab, although you’ll obviously have to experiment with what paths the script needs, and google has plenty of info on editing crontabs.

          • For some reason, every a manual upload of a file doesn’t land in my dropbox. I tried ./dropbox-uploader.sh upload /home/pi/ocr_pi.png but the file never shows up in my dropbox. How do I specify where it should show up in dropbox?

            Regarding crontab, yes once very couple of hours would be enough anyone.

          • Try re-reading the documentation…
            https://github.com/andreafabrizi/Dropbox-Uploader

          • Well, I managed to get a file to dropbox with
            ./dropbox_uploader.sh upload /home/pi/frame/photos/*.* /mydropboxdirectory
            but this only does upload, the other command only download or delete. What to I have to specify to rsync a dropbox directory with a directory on the Raspberry? Also it didn’t upload the folders in the directory only the photos in that directory..

          • Baby step success! The recursive upload works when I just write ./dropbox_uploader.sh upload /home/pi/frame/photos /mydropboxdirectory

          • So how I sync? :-))

          • I’ve got no idea, that’s why I said you’ll need to read the documentation and experiment with different paths…

          • Hmm, I find it hard to believe that I am the first one who wants to sync a directory, not just up- and download something… :-(( Andrea’s script is so great and he surely must have thought of that…

          • Ahhhh, I think I see what you’re saying now…
            There’s no way for Andrea’s script to offer “sync” functionality, because if (either by accident or deliberately) the same file exists both in Dropbox *and* on the Pi, then Andrea’s script has no way of knowing which is the correct version! That’s why it’s “upload only” or “download only” – it’s up to you to make sure the files are being copied in the right direction ;)
            To do proper two-way sync you’d need to use the official Dropbox client, and unfortunately that’s not available for ARM Linux… (the Pi uses an ARM CPU).
            Sounds to me like your best option might be to have one subfolder for copying from the Pi up to Dropbox, and a different subfolder from copying from Dropbox down to the Pi? (and you’d need a separate cronjob for each)

          • P.S. Have a look at some of the closed feature requests…
            https://github.com/andreafabrizi/Dropbox-Uploader/issues?q=is%3Aissue+sync

  34. Hi,

    Forgive me if it seems stupid but I’m new to the Pi.

    This is a great piece of code and I got it to work (third time after typing carefully). Has anybody tried the “Move” command? What I’m trying to do is to take some time elapse photography and I don’t want the pictures stored on the SD card. I assumed that move was the same as upload except that it would delete the file after it had been uploaded. However, although I can upload successfully, move comes back “FAILED”.

    I suppose the alternative would be to upload the file and then remove it from the Pi but I’m not sure either how to do that in Python nor how to make sure that the file has been uploaded before it gets deleted.

  35. Fantastic – up and running in 15 minutes, thank you so much.

  36. This is fantastic! Thanks for sharing!

  37. Hi, I have followed these instructions but when I run the command to upload using “dropbox_uploader upload file_name “it always goes into the ‘first time ‘ routine!

    What am I doing wrong?

  38. OK, I have found my error! I was exiting the .sh file before the link was made to dropbox.

  39. Big help, many many thanks!

  40. Is it also possible to sync the data from dropbox with a folder on the Raspberry Pi? It would be great to update Websites with just uploading the files on dropbox! The best would be if it done automatically but it wouldn’t be a problem to do it by hands! ;)

  41. Sorry is there guide for automating the process? I have my pi set up as a CCTV and want to sync all content from /var/www/media to my dropbox folder.

    Thnks

  42. “Once you’ve entered your keys and answered the question “app” or “full”, your Pi will request an authorisation token and you will be given a web URL you need to visit to activate it…

    DropBox API authorisation

    This is the part which annoyed me, as I was using a different computer to ssh into the Pi and couldn’t cut and paste the “rather tricky to type accurately” URL. But once you’ve got past that hurdle it should all just work. :)” – from this website….

    “you’ll need to give Dropbox-Uploader permission to all Dropbox files”. – from her github website…… how do I give dropbox uploader permission to all dropbox files? My Access Token request keeps failing.

    • Nevermind, i got it to work. I had to re-enter my key and secret codes, then it gave me a new web address. thanks!

  43. […] upload the (4Gb) RasPiO Duino assembly video from there. So I decided to implement the same sort of dropbox upload that I used for RasPiCamcorder 2. This gives you the option to get high quality video without needing good bandwidth, as long as you […]

  44. New question. Now that im linked to my dropbox, how do I upload a file? I created a document and saved it, but when I try to run the upload script I get the usage command list. what am i doing wrong?

  45. Thanks for another awesome tutorial Alex. All working fine on my Model A and A+, it took longer for the updates to install than to setup the Dropbox links. :)

    As a side note on apt-get ‘s I only discovered today: ‘sudo apt-get clean’
    It cleared nearly 1GB off of each of my two SD cards – Does this command need promoting? If ‘yes’ then I think ‘you’re the man! ;)
    Thanks again.

  46. Thanks for the tutorial, really helped me, I was trying to use a dynamic DNS host but it wouldn’t work. I was trying to get my Pi to update my home external IP address so I can connect back via VPN.

    For anyone interested here is my crontab, nothing fancy, basically it uses wget to retrieve my external IP address and create a log file with it, then Dropbox-Uploader.sh uploads that to my Dropbox App folder. I can then use the IP to amend my openvpn file to the correct IP address.

    /31 * * * * /home/pi/Dropbox-Uploader/dropbox_uploader.sh upload “/home/pi/cron.log” “/Apps/cron.log”
    /30 * * * * /usr/bin/wget -qO- “ifconfig.me/ip” > /home/pi/cron.log

    One thing that I did stumble on (and is documented in the readme.md (but hey, who reads those?!) was setting up the crontab job.

    I was using “sudo crontab -e” but obviously the Dropbox-Uploader.sh script was ran as pi, therefore any cron job that was set using “sudo crontab -e” won’t work as its not the correct user. Use “sudo crontab -e -u pi” to specify the user pi cron jobs and put the cron job in there. This now works and I am a happy bunny.

    Again thanks, I was ready to give up trying to find a simple way to retrieve my IP address, this works perfectly.

    • Oops, small error in the cron job, remove the “/” from the time, mistakenly added. Should be this:

      31 * * * * /home/pi/Dropbox-Uploader/dropbox_uploader.sh upload “/home/pi/cron.log” “/Apps/cron.log”
      30 * * * * /usr/bin/wget -qO- “ifconfig.me/ip” > /home/pi/cron.log

  47. Hello All, I have installed and authorized the code fine, but I am having problems getting the upload command to do so to the folder I specify in the destination. My command is: dropbox_uploader upload README.md “Camera/” hoping to upload the unique file name each time to the Camera folder on Dropbox. Even if I create the folder first, the command only replaces it with a file with the name “Camera”. For some reason it’s not recognizing the “/”. Is there some other way to do it? Am i missing the syntax? TIA

    • FYI – The README.md file is just for testing purposes.

    • Have you tried

      dropbox_uploader upload README.md “Camera/README.md” 
      • Thanks, and I do not wish to sound snarky here at all, but certainly that will work for that specific file. The issue occurs when I would hope to upload multiple files (with their unique names generated by the RPi Motion program for example) to the same directory. That is why I tried testing it as I did, so I could be sure the final project would work. In theory, using dropbox_uploader upload README.md “Camera/” should do the same thing, but it doesn’t. Thanks

        • The dropbox_uploader documentation is at https://github.com/andreafabrizi/Dropbox-Uploader#usage
          I similarly don’t mean to sound snarky, but if dropbox_uploader isn’t working the way you think it should, you should try reading the docs in more detail and/or file an issue at the project website.

          AFAIK Alex never claimed to be a dropbox_uploader expert? ;-)

          Looking at the examples, I suspect you might want to try something like:
          ./dropbox_uploader.sh -s upload *.jpg /Camera

  48. I did read the usage and the -s option will only skip a preexisting file. That is of no help here. The “/” in front of the directory “Camera” also only creates a file on the Dropbox. So both the usage as documented of putting the “/” after the directory name (as I had originally tried) and prior to it (as you suggest) only creates a file with that directory name. I also tried the “/” both in front and behind the directory (/Camera/) and that also only created a file with the name Camera.

    • In which case it sounds like maybe you need to file a bug report? :-/
      Did you also experiment with the -d option, which might give you some clues as to where it’s going wrong?

  49. OK, I am the one person for which things never quite work; I am using a Rpi 2; Jessie. Follow directions faithfully (I think) and all goes well up until

    $ ./dropbox_uploader.sh
    ./dropbox_uploader.sh: line 5: syntax error near unexpected token `newline’
    ./dropbox_uploader.sh: line 5: `’
    pi@raspberrypi ~ $

    I look at dropbox_uploader.sh and, indeed, line 5 is

    What did I do? Or, what should I do?

    Thanks in advance.

    Rich

  50. Hi!
    Great instuctions! It’s working fine to upload but I have a problem (python):

    I’m using a picamera and PIR-sensor as a surveillance camera which records videos when it finds movement. I have managed to name the files differently that the camera captures, but with the line: from subprocess import call
    photofile = “/home/pi/Dropbox-Uploader/dropbox_uploader.sh upload /home/pi/photo00001.jpg photo00001.jpg”
    call ([photofile], shell=True) I can only choose 1 (!) file that the program constantly uploads, and no one else. Does anyone know how to choose files that will be named video0, video1, video2 etc (this is how the files are named from the recordings)? To clarify – How can I change the existing mentioned line so that it chooses video0 in the first loop, video1 in the second and so on?

    Johan

    • photofile = “/home/pi/Dropbox-Uploader/dropbox_uploader.sh upload /home/pi/photo00001.jpg photo00001.jpg”
      

      With “photo00001.jpg” you are just using a constant, not a variable. That line will always upload photo00001.jpg as photo00001.jpg

      You need to use a variable in order to upload whichever file you set the variable to.

      • i.e. something like:

        from subprocess import call
        import os.path
        myfile = “/home/pi/video1.h264”
        photofile = “/home/pi/Dropbox-Uploader/dropbox_uploader.sh upload %s %s” % (myfile, os.path.basename(myfile))
        call([photofile], shell=True)

        The variables will get interpolated into the string, and the photofile variable will end up looking like:
        /home/pi/Dropbox-Uploader/dropbox_uploader.sh upload /home/pi/video1.h264 video1.h264

  51. Thanks for the fast answers!
    Alex, I realised that but didnt know how to put that filename into the photofile =… I tried with filename = video + (j) where j starts in 1 but that did not work very well…
    AndrewS, I wrote as you suggested but only the first file is uploaded to dropbox (named video0). I will past the code below if you want to take a look at it and see if anything is wrong.

    from gpiozero import MotionSensor
    from time import sleep
    from picamera import PiCamera
    from datetime import datetime
    from subprocess import call
    import os.path

    myfile = “/home/pi/video0.h264”

    #Declare picamera and motionsensor
    camera = PiCamera()
    pir=MotionSensor(4)
    sleep(5)

    #Record 3 times if motion
    for i in range(3):
    pir.wait_for_motion()
    camera.start_preview()
    camera.start_recording(‘/home/pi/video%s.h264’ % i)
    sleep(5)
    pir.wait_for_no_motion()
    camera.stop_recording()
    camera.stop_preview()
    photofile = “/home/pi/Dropbox-Uploader/dropbox_uploader.sh upload %s %s” % (myfile, os.path.basename(myfile))
    call ([photofile], shell=True)
    print (“Has recorded 3 times”)

    Johan

    • Easily fixed….

      Delete the first line with “myfile” on, and then change:
      camera.start_recording(‘/home/pi/video%s.h264’ % i)

      to:
      myfile = ‘/home/pi/video%s.h264’ % i
      camera.start_recording(myfile)

      • Once again – Thank you :) Although I realised that it would be easier if I wrote:

        name= datetime.now().strftime(“….h264”)
        myfile = ‘/home/pi/’ + name

        … to name the files after date and time, and then the way you described.
        I am a bit new to Raspberry Pi and this is my first project, as you might understand ;)

        Johan

  52. Hello AndrewS
    How can I download multiple files at once, lest say photo 1, photo 3, photo7, photo 10………..

    • I guess you could do it in a loop.

      myfiles = [‘photo1.jpg’, ‘photo3.jpg’, ‘photo7.jpg’, ‘photo10.jpg’]
      for myfile in myfiles:
      photofile = “/home/pi/Dropbox-Uploader/dropbox_uploader.sh upload /home/pi/%s %s” % (myfile, myfile)
      call ([photofile], shell=True)

    • This also works… simple command line:

      ./dropbox_uploader.sh -s download / photos

      (downloads all files—in my case .jpg files—and copies them to a directory on the pi called photos)… the -s flag skips existing photos, so essentially syncs the remote Dropbox folder to the pi.

  53. when I use the line
    photofile = “/home/pi/Dropbox-Uploader/dropbox_uploader.sh upload /home/pi/” + newest
    it returns an error photofile: not found
    my photos are date stamped 2016-07-11_2140.jpg
    they are taken every ten mins, so how can I change “photofile” to work on my photos?
    thanks for the help, and love this lesson! I can’t wait to get it up and running and save my files to my dropbox vs raspberry pi, keeping my space open

  54. Hello, I have a programm that takes pics and videos and uploads them to dropbox automatically. That works great thanks for that nice tutorial. My Problem now is that it also saves them locally on the raspberry Pi which I think is not great because There is limited space on it and I’m afraid it might get slow after a while. Can I somehow delete the picture I took in that same programm without doing it through the command prompt? Maybe like a remove funktion which removes the files from the raspberry pi after it uploaded them. The program only takes one picture per run so I am not having any sequence.

  55. Thank you for the article.

    Unfortunately I’m having trouble linking the dropbox app. When I run the dropbox_uploader script for the first time, it asks me for Access Token ID. After pasting that, it asks for confirmation (y/n). After entering ‘y’, it says “The configuration has been saved.” That’s it. It does not give me any web address. Plus it never asks me for “App Key” and “App Secret”.
    After that, when I try running “dropbox_uploader upload”, it goes into the help menu. Always.
    I have tried rebooting.
    I have tried re-creating a new app.
    I have tried removing the configuration file and tried running the script again. But nothing has helped so far.
    I have tried re-installing Dropbox-Uploader as well.

    Could you please point me where could I be going wrong. Thanks.

    • I am seeing the exact same issue..
      Did you get it to work yet ?? This is frustrating.. its not giving any error message.. simply gives the help menu.. tried with debug option as well.. but that doesnt give any clue.

      • pi@raspberrypi:~/Dropbox-Uploader $ sudo ./dropbox_uploader.sh upload /home/pi/clips/Clip_20161119_105611.mp4
        Dropbox Uploader v1.0
        Andrea Fabrizi – andrea.fabrizi@gmail.com

        Usage: ./dropbox_uploader.sh [PARAMETERS] COMMAND…

        Commands:
        upload
        download [LOCAL_FILE/DIR]
        delete
        move
        copy
        mkdir
        list [REMOTE_DIR]
        monitor [REMOTE_DIR] [TIMEOUT]
        share
        saveurl
        search
        info
        space
        unlink

        Optional parameters:
        -f Load the configuration file from a specific file
        -s Skip already existing files when download/upload. Default: Overwrite
        -d Enable DEBUG mode
        -q Quiet mode. Don’t show messages
        -h Show file sizes in human readable format
        -p Show cURL progress meter
        -k Doesn’t check for SSL certificates (insecure)

        For more info and examples, please see the README file.

  56. Damn…me
    @ Haris Ashraf — make sure you are providing the 2 arguments after upload.. (local file) (remote file)

    above issue happens when you are supplying only local file name..
    so I changed from
    pi@raspberrypi:~/Dropbox-Uploader $ sudo ./dropbox_uploader.sh upload /home/pi/clips/Clip_20161119_105611.mp4
    to
    pi@raspberrypi:~/Dropbox-Uploader $ sudo ./dropbox_uploader.sh upload /home/pi/clips/Clip_20161119_105611.mp4 Clip_20161119_105611.mp4

    and it worked just fine..

  57. Hello guys. I’ve used the dropbox_uploader script for a while, however, always wanted an automatic sync from Dropbox and from the pi to Dropbox. Eventually, I’ve wrote a client myself :) The client is written in Java. Feel free to use it. There is still room for improvement, however, the basic sync works both ways. You can view the sources and download the client from github: https://github.com/yuriytkach/dsync-client

  58. Hello! Is there any way to calculate the time of upload of a file on the Pi-side of the process?

    • Not as far as I know unless you write custom code for it. I suppose you could run a connection speed test and guesstimate using the file size, but it’s something that would take some time and effort to work out.

    • If you’re concerned about how long the files are taking to upload, I guess you could modify the picture-taking part to capture the images in a lower resolution, to give you smaller filesizes.

  59. I’m having trouble getting Dropbox-Uploader installed on my Pi. Having the same problem that Haris Ashraf described above. Basically it appears to be asking for something different then what is described in the text above initially. I gave it the App Key to start, which it ask me if that was correct, I said Y(es) and the script ended. It never asked for the App Secret or the Full/Single option. Not sure how to proceed at this point. Appreciate any help.

  60. Rest everything worked fine but after giving the generated access token, the script ended with no further statement. Any help here?

    pi@raspberrypi:~/Dropbox-Uploader $ ./dropbox_uploader.sh

    This is the first time you run this script, please follow the instructions:

    1) Open the following URL in your Browser, and log in using your account: https ://www.dropbox.com/developers/apps
    2) Click on “Create App”, then select “Dropbox API app”
    3) Now go on with the configuration, choosing the app permissions and access re strictions to your DropBox folder
    4) Enter the “App Name” that you prefer (e.g. MyUploader16582178784593)

    Now, click on the “Create App” button.

    When your new App is successfully created, please click on the Generate button
    under the ‘Generated access token’ section, then copy and paste the new access token here:

    # Access token: iKH8InCg-6AAAAAAAAAAD4F1mZz4W2HT-YYZjq8BPkxT_0tuX6u____PZD4X3yL_

    > The access token is iKH8InCg-6AAAAAAAAAAD4F1mZz4W2HT-YYZjq8BPkxT_0tuX6u____PZD4X3yL_. Looks ok? [y/N]: y

    The configuration has been saved.
    pi@raspberrypi:~/Dropbox-Uploader $

  61. Excellent super useful script for unattendend scheduled backups; in fact I find it perfect for my database weekly backups because I only want to upload compressed backups from the Pi to dropbox without risking filling my RPi sdcard available space, in case someone unadvertedly uploads some big stuff to dropbox

  62. And this is useful yet again 😉 Thanks!

  63. When i run the script at boot up, it shows “error uploading file”. i have tried copying the file to root as mentioned above. It works file when i run it manually through terminal or desktop.
    Thank you

  64. Is their any to upload image form raspberry pi to google drive? in the same manner as the as dropbox. Using python script.

Leave a Reply