Dropbox Help
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Dropbox Help
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.
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
Re: Dropbox Help
Sorry, im struggling to understand fully. I am using the code out of files-download but the part im struggling with is
Jamie
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.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"}
Jamie
Re: Dropbox Help
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.
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
Re: Dropbox Help
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...
This is the code on the button which also uses your code:
Thanks again
Jamie
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
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
Jamie
Re: Dropbox Help
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.
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
Re: Dropbox Help
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
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
Re: Dropbox Help
You can do a repeat loop through the paths and collect the last items and just list them.
gmcrev
Re: Dropbox Help
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:
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
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
Thanks
Jamie
Re: Dropbox Help
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
eg:
repeat for each line rLine in pText
put fGetlastChunk(pDelim,rLine) & cr after tList
end repeat
gmcrev
Re: Dropbox Help
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
Thanks
Jamie
Re: Dropbox Help
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
use a repeat loop so that for each file, get the last item
and add it to a list of file names
gmcrev
Re: Dropbox Help
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?
-
- VIP Livecode Opensource Backer
- Posts: 7229
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Dropbox Help
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:put the last of item of tline into DropBoxFileListLast
Code: Select all
put the last item of tline & cr after DropBoxFileListLast
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Dropbox Help
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
Jamie