
Enclosed the correct one ... I hope

Guglielmo
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller


Code: Select all
on mouseUp
   -- upload
   if (the uTokenKey of this stack) is empty then
      exit mouseUp
   end if
   put empty into field "flAnswer"
   answer file "Choose a file to upload" --the name of the file is "ProvaBeep.livecode"
   if it is empty then exit mouseup
   set the itemdelimiter to slash
   put last item of it into tname
   
   put URL ("binfile:" & it) into tFile
   put base64Encode(tFile) into tFile
   
   put phx_DropboxWriteFile("sandbox", tname, "application/octet-stream", true, tFile) into field "flAnswer"
end mouseUpCode: Select all
on mouseUp
    -- download
    if (the uTokenKey of this stack) is empty then
        exit mouseUp
    end if
    put empty into field "flAnswer"
    
    put phx_DropboxReadFile("sandbox", "ProvaBeep.livecode") into tFile
    if "Err: " is  in tFile then
        put tFile  into field "flAnswer"
        exit mouseup
    end if
    set the defaultFolder to specialFolderPath("desktop")
    ask File "Save the file:" with  "ProvaBeep.livecode"
    if it is not empty then
        put  base64Decode(tFile) into URL ("binfile:" & it)
    end if
end mouseUpCode: Select all
repeat
...
put  Drop_Download(tPAthFrom, tPathTo)
..
end repeat
function Drop_Download pPAthFrom, pPathTo
    if (the uTokenKey of stack "phxDropboxLib") is empty then
        return "Err: not authorized"
    end if
    --the actual download
    put phx_DropboxReadFile("sandbox", pPAthFrom) into tFile
    --tFile AT THIS POINT HAS DATA INTO IT (PROBABLY NOT WELL FORMATTED?)
    if "Err: " is  in tFile  then
        return tFile
    end if
    if "can't open file" is in tFile then
        return "Err: " & tFile
    end if
    if pPathTo is not empty then
        try
            put  base64Decode(tFile) into URL ("binfile:" & pPathTo)
        catch tErr
            answer tErr
        end try
    end if
end Drop_Download