Advertisement
Guest User

dropbox

a guest
Oct 7th, 2012
569
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. local tVarargs = {...}
  2. local sDropboxFilename = tVarargs[1]
  3. local sLocalFilename = tVarargs[2]
  4. local iDropboxUser = 46643202
  5. --[[ Enter your dropbox user ID on the line above.
  6. To get your ID copy a public link and it's the long
  7. number after the /u/. ]]
  8.  
  9. if #tVarargs ~= 2 then
  10.         print("Usage: dropbox [remote filename] [filename]")
  11.         return
  12. elseif not http then
  13.         print("Please enable the HTTP API to used this program.")
  14.         return
  15. elseif iDropboxUser == 0 then
  16.         print("Please edit this program and change the Dropbox ID on line 4 to your own ID.")
  17.         return
  18. end
  19.  
  20. local sVersion = string.sub(os.version(), -3)
  21. local fileGet = {}
  22. if sVersion == "1.4" then
  23.         fileGet = http.get("https://dl.dropbox.com/u/" .. iDropboxUser .. "/" .. sDropboxFilename)
  24. else
  25.         fileGet = http.get("http://dl.dropbox.com/u/" .. iDropboxUser .. "/" .. sDropboxFilename)
  26. end
  27.  
  28. if fs.exists(sLocalFilename) == true then
  29.         fs.delete(sLocalFilename)
  30. end
  31.  
  32. local tFile = fs.open(sLocalFilename, "w")
  33. tFile.write(fileGet.readAll())
  34. tFile.close()
  35.  
  36. fileGet.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement