Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

dropbox

By: a guest on Oct 7th, 2012  |  syntax: Lua  |  size: 1.09 KB  |  views: 113  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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()