Dropbox Help

Bringing the internet highway into your project? Building FTP, HTTP, email, chat or other client solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

gmccarthy
Posts: 62
Joined: Sat Feb 17, 2007 4:56 am
Location: Australia

Re: Dropbox Help

Post by gmccarthy » Tue Mar 15, 2016 1:46 pm

eg.Header to include:
Lets say the file name that you clicked on was testfile1.txt in the dropbox app folder.

Authorization: Bearer <<AccessToken>>
Content-Type:
Dropbox-API-Arg: {"path":"/testfile1.txt"}

You might put into a variable the following and just replace MyFilename with the clicked text.
Authorization: Bearer <<AccessToken>>
Content-Type:
Dropbox-API-Arg: {"path":"/MyFilename"}

See the code in the files-download.
gmcrev

Jamie37
Posts: 53
Joined: Sat Dec 19, 2015 1:45 pm

Re: Dropbox Help

Post by Jamie37 » Tue Mar 15, 2016 2:08 pm

Sorry, im struggling to understand fully. I am using the code out of files-download but the part im struggling with is
You might put into a variable the following and just replace MyFilename with the clicked text.
Authorization: Bearer <<AccessToken>>
Content-Type:
Dropbox-API-Arg: {"path":"/MyFilename"}
I have the selected text in a variable but dont know how to use that variable as the file name. Also while I am asking, How would I only show the file name and not the entire path. Sorry for not understanding and im very grateful for your help.

Jamie

gmccarthy
Posts: 62
Joined: Sat Feb 17, 2007 4:56 am
Location: Australia

Re: Dropbox Help

Post by gmccarthy » Tue Mar 15, 2016 9:40 pm

Replace "MyFilename" with the file name.
You can cut the file path as the last "/" in various ways.
eg. set the itemdelimiter to "/" then get item -1 of the file path.
gmcrev

Jamie37
Posts: 53
Joined: Sat Dec 19, 2015 1:45 pm

Re: Dropbox Help

Post by Jamie37 » Tue Mar 15, 2016 10:43 pm

So does this mean I put my variable which contains the filename in the header field or do I put it into code because im really stuck on how to actually use the file name. I know you say replace the filename with my filename but the filename needs to be the variable because thats what contains my filename. Below is the code on the list which is your code...

Code: Select all

global gSelectedFile

on mousedown
   put the hilitedtext of me into gSelectedFile
   show button "View"
end mousedown

on selectionchanged
   put the hilitedtext of me into gSelectedFile
   show button "View"
end selectionchanged
This is the code on the button which also uses your code:

Code: Select all

global gSelectedFile

on mouseUp
   DB2_download
end mouseUp

on DB2_download
   if not fGetDropboxOnline() then
      answer "Dropbox HTTPS connection NOT available for DropBox_API_2"
      exit DB2_download
   end if
   ClearResponseFlds
   --
   put fld "Post_files-download" into tPost
   --put empty into tPost
   put fld "Header_files-download" into tHeader
   put "https://content.dropboxapi.com/2/files/download?" into tURL
   --
   put fGetDropboxAPI2(tHeader,tPost,tURL) into tResponse
   put tResponse into fld "ResponseJson"
   //put fGetResponseTextFromResponse(tResponse) into fld "ResponseText"
end DB2_download
Thanks again
Jamie

gmccarthy
Posts: 62
Joined: Sat Feb 17, 2007 4:56 am
Location: Australia

Re: Dropbox Help

Post by gmccarthy » Wed Mar 16, 2016 2:34 am

You need to use:
put fGetDropboxAPI2(tHeader,tPost,tURL)
You need to put hold the various inputs to the function in the variables: tHeader,tPost,tURL
You can put the file name selected into a variable then use that variable to replace the header text in another variable.
gmcrev

Jamie37
Posts: 53
Joined: Sat Dec 19, 2015 1:45 pm

Re: Dropbox Help

Post by Jamie37 » Thu Mar 24, 2016 11:03 pm

Hi gmccarthy,

Sorry for the late reply, I have been very busy. I have sorted the problem I had with being able to click the file and os on and thats working great. Going back to the other thing I wanted to do. It was to just show the file name. When I use your suggestion of Item -1, I only get the very last file as I have three files in the folder at the minute and there will probably be more. Is there a way to just show the the file name of each file?

Thanks
Jamie

gmccarthy
Posts: 62
Joined: Sat Feb 17, 2007 4:56 am
Location: Australia

Re: Dropbox Help

Post by gmccarthy » Thu Mar 24, 2016 11:45 pm

You can do a repeat loop through the paths and collect the last items and just list them.
gmcrev

Jamie37
Posts: 53
Joined: Sat Dec 19, 2015 1:45 pm

Re: Dropbox Help

Post by Jamie37 » Fri Mar 25, 2016 12:05 am

I have a repeat loop in place now to try it but the problem is that it gets the last item of each line but will then only put the last item of the last line into the field. THis si the repeat code I have:

Code: Select all

repeat for each line tline in tDropBoxFileList 
         put the last of item of tline into tDropBoxFileListLast
         answer tDropBoxFileListLast
         put tDropBoxFileListLast into fld "DropBoxFileList"
      end repeat
Sorry to keep asking but there was one other thing. When I have a file thats the same name for uploading, mine will not upload even when I set the path to automatically add a number to the end like your documentation in the API says? Do you have any ideas why this would be?

Thanks
Jamie

gmccarthy
Posts: 62
Joined: Sat Feb 17, 2007 4:56 am
Location: Australia

Re: Dropbox Help

Post by gmccarthy » Fri Mar 25, 2016 12:51 am

Build a list with a repeat loop on he list of files
eg:
repeat for each line rLine in pText
put fGetlastChunk(pDelim,rLine) & cr after tList
end repeat
gmcrev

Jamie37
Posts: 53
Joined: Sat Dec 19, 2015 1:45 pm

Re: Dropbox Help

Post by Jamie37 » Fri Mar 25, 2016 1:09 am

Im really grateful for your help but if i'm honest I don't really know what that piece of code means. Id rather understand it rather than just copy and pasting. Would you be able to explain it to me if thats ok so I understand.

Thanks
Jamie

gmccarthy
Posts: 62
Joined: Sat Feb 17, 2007 4:56 am
Location: Australia

Re: Dropbox Help

Post by gmccarthy » Fri Mar 25, 2016 1:23 am

get the list of files in the folder
use a repeat loop so that for each file, get the last item
and add it to a list of file names
gmcrev

Jamie37
Posts: 53
Joined: Sat Dec 19, 2015 1:45 pm

Re: Dropbox Help

Post by Jamie37 » Fri Mar 25, 2016 2:10 am

That's Great! Thanks for the explanation. However it is still giving me the full file name and when I use item -1, if still only gives me the very last one?

gmccarthy
Posts: 62
Joined: Sat Feb 17, 2007 4:56 am
Location: Australia

Re: Dropbox Help

Post by gmccarthy » Fri Mar 25, 2016 2:30 am

set your itemdel to slash
gmcrev

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7214
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Dropbox Help

Post by jacque » Fri Mar 25, 2016 4:35 pm

put the last of item of tline into DropBoxFileListLast
When you put something into a variable, it replaces the current value with the new one. As you loop through the files, each loop replaces the previous content until by the end only the last filename remains. If you are trying to make a list, you want to put the new value after the existing list:

Code: Select all

put the last item of tline & cr after DropBoxFileListLast
There was an extra "of" in the original which I removed.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Jamie37
Posts: 53
Joined: Sat Dec 19, 2015 1:45 pm

Re: Dropbox Help

Post by Jamie37 » Fri Mar 25, 2016 10:54 pm

Thank you both for your input. I really appreciate your help and I believe everything is now sorted. Thanks gmccarthy, your Dropbox API is great!

Jamie

Post Reply

Return to “Internet”