122 posts
Location
gps.locate()
Posted 07 August 2015 - 03:57 PM
Hi,
So I was bored, and I decided to add to my program that already supports downloading and running programs direct from Dropbox. However, when attempting to use my code (which I have lost, because I am stupid), it says "Connecting to Dropbox…" then prints "Failed." I have read through the files_put section of the Dropbox HTTP API and I am still confused as to why it is failing. If anyone can help me, I will be very grateful :D/>
Any help will be appreciated,
_Zircon_
1426 posts
Location
Does anyone put something serious here?
Posted 07 August 2015 - 05:10 PM
I knew I wrote this for a reason! Here is
a script I wrote a while back which can upload and download files from Dropbox. I wasn't very good at Lua back then so you probably want to clean it up a bit.
122 posts
Location
gps.locate()
Posted 07 August 2015 - 05:37 PM
Thank you SquidDev! Do you mind if I put that "put" function in my program, just so I don't have to use different programs for different purposes?
EDIT: Or can I pick and choose? That is a really useful program!
Edited on 07 August 2015 - 03:37 PM
1426 posts
Location
Does anyone put something serious here?
Posted 07 August 2015 - 06:20 PM
Thank you SquidDev! Do you mind if I put that "put" function in my program, just so I don't have to use different programs for different purposes?
EDIT: Or can I pick and choose? That is a really useful program!
Pick and choose, clean up, do whatever you want. You'll probably want to strip out a lot of the functionality - not sure how much you'll need.
122 posts
Location
gps.locate()
Posted 07 August 2015 - 07:03 PM
Okay,thank you SquidDev!
122 posts
Location
gps.locate()
Posted 07 August 2015 - 07:59 PM
Damn. SquidDev, your code is working perfectly! Thank you, the only problem is everything has worked up until now. I am trying to fulfill the token request by going to the link provided, but when going to
https://www2.dropbox.com/1/oauth/authorize?oauth_token=[Not seeing this], both Chrome AND Microsoft Edge error saying it is an unsecure site because Dropbox has decided not to use two different certificates, so yah. Can't complete it, if someone has a work around or if the links have changed, please tell me :D/>
122 posts
Location
gps.locate()
Posted 07 August 2015 - 09:18 PM
Anyone?
1426 posts
Location
Does anyone put something serious here?
Posted 07 August 2015 - 09:28 PM
Sorry. Replace www2 with just www. Looks like dropbox changed their URL. You might want to have a read of
Dropbox's documentation - I use OAuth 1.0 not 2.0 so you can ignore the docs on the latter.
122 posts
Location
gps.locate()
Posted 08 August 2015 - 10:25 AM
Hey, SquidDev, how do I re-enabled uploading? I have fixed the error (there was an error whilst writing to the config file that failed the upload), but you have made it say "Sorry, uploading doesn't work."
Code on Pastebin
1426 posts
Location
Does anyone put something serious here?
Posted 08 August 2015 - 10:27 AM
Hey, SquidDev, how do I re-enabled uploading? I have fixed the error (there was an error whilst writing to the config file that failed the upload), but you have made it say "Sorry, uploading doesn't work."
Code on Pastebin
I'll have another look at the script, and probably rewrite it. I seem to remember there was an issue with uploading which was very hard to debug and so I gave up and disabled it.
Edited on 08 August 2015 - 08:30 AM
122 posts
Location
gps.locate()
Posted 08 August 2015 - 10:46 AM
Okay, so I seem to have fixed uploading, but now, I come across an error saying "
dropbox:598: attempt to index ? (a nil value)"
This was fine before I re-enabled uploading, so…. I looked at that line, and it is the one that says:
local result_content = response.readAll()
EDIT: Umm.. That was weird ^_^/>
EDIT2: I think I've found the problem, it cannot retrieve the token request URL for some reason, because now that I have changed it to check if response exists, it errors on the line:
response.close()
EDIT3: Okay, so it turns out, it was my fault ;)/> I was using the wrong APP KEY and APP SECRET, but after using the correct ones, it errors saying: "
dropbox:606: bad argument: string expected, got nil"
Edited on 08 August 2015 - 09:41 AM
1426 posts
Location
Does anyone put something serious here?
Posted 08 August 2015 - 12:51 PM
So I
kinda rewrote it. In the current form this is an fs style wrapper, but should easily be changed to be more flexible. It should be much more flexible than the original version though and is less likely to explode in random places. Also, it is about 1/3 of the size. Uploading/downloading works through .open instead which I think is kinda cool.
122 posts
Location
gps.locate()
Posted 08 August 2015 - 01:00 PM
Okay, does it still do all the functions the other one does ?
EDIT: It isn't obvious what I can do, as you haven't added something to print the usage…
Edited on 08 August 2015 - 11:03 AM
1426 posts
Location
Does anyone put something serious here?
Posted 08 August 2015 - 01:02 PM
Okay, does it still do all the functions the other one does ?
I removed share. Though, feel free to add it back in. Also, you'll have to handle directory upload/download yourself but that is fairly trivial.
122 posts
Location
gps.locate()
Posted 08 August 2015 - 01:46 PM
Okay, does it still do all the functions the other one does ?
I removed share. Though, feel free to add it back in. Also, you'll have to handle directory upload/download yourself but that is fairly trivial.
Okay, can you add a printUsage function to it so I know what to do? :)/>
1426 posts
Location
Does anyone put something serious here?
Posted 08 August 2015 - 03:37 PM
Okay, can you add a printUsage function to it so I know what to do? :)/>
I've rewritten
the old CLI as well, which is fairly well commented. However I'll give you a run down:
There are three functions: requestToken and accessToken handle getting the original app key. Once you've got that the main one is create.
os.loadAPI("dropbox")
local drop = dropbox.create {
app_key = "foobar",
app_secret = "foobarbaz",
token = "hsffd",
token_secret = "hfdsjfhskj"
}
If you look at your old dropbox_config file it should be pretty obvious which ones are which. Then you can use the API like the normal fs api:
for _, v in pairs(drop.list("/")) do
print(v)
end
local handle = v.open("foobar", "r")
print(handle.readAll())
handle.close()
Note however, it may take some time because network actions always add some delay. In the script I've linked I make use of the parallel API to download multiple files at once.