dropbox read function question

Hey guys,

I’ve created an app for my researchers to draws house plans then allows them to send the data to their dropbox. In the dropbox, I’ve made a python script that changes the data back in a PDF of the house plan.

The app uses code created by @aciolino and modified by @briarfox dropbox script, which I cannot seem to find online anymore.

I thought the app is done but the researchers wanted an additional function that allows the user to access their dropbox and read the data files stored there. I spent the past few days trying to get the read and search code to work, there are no error messages, but it also does not return any value or data.

Some initial code:

globalAppKey=**********************
globalSecret=*****************

DropBox = class()
local urlencode

function DropBox:init(root)
 if root == "reset"  then
        self.appKey = globalAppKey
        self.appSecret = globalSecret
        self:RunAuth()
    else
        self.root = root and root.."/" or "dropbox/"
        self.appKey = globalAppKey
        self.appSecret =globalSecret
        self.root = root or "dropbox"
    end
 
    if self.appKey ==nil or self.appSecret == nil then self:RunAuth() end
    self.params = nil        
    end

The code for “dropbox:Read”:

function DropBox:Read(filename, callback)
local cb = callback or nil
    local params = self:BuildParams()
    local url = urlencode("https://api-content.dropbox.com/1/files/"..self.root.. filename) .. params
    http.request(url,
        function(data,status,headers) 
            if cb ~= nil then cb(data) end
        end,
    function(url)httpError(d,url) end)
end

The code for “dropbox:Search”:

function DropBox:Search(query, callback)
    local params = self:BuildParams()
    local searchparams = params .. "&query=" .. query
    local url = urlencode("https://api.dropbox.com/1/search/"..self.root).. searchparams
    DropBox:_GetJSONResult(url, callback)
end

I am at my wits end, so I want to ask what am I doing wrong? I don’t understand where it would return data after calling the url.

Hey guys, I found the solution after hours and hours of playing with the function.

Just had to print the function(data)