0

i am trying to read and write a folder in Dropbox. so i have registered my app in DropBox ..

Details of my App is..

Permission type App folder

App folder name hello

now the "hello "folder is in this directory at the moment

https://www.dropbox.com/home/Apps/

so when i do this

  $files = $this->DropboxApi->ls( );
        pr($files);

the result i am getting is this

Array
(
    [Dropbox] => Array
        (
            [hash] => *****************
            [thumb_exists] => 
            [bytes] => 0
            [path] => /
            [is_dir] => 1
            [size] => 0 bytes
            [root] => app_folder
            [contents] => Array
                (
                )

            [icon] => folder
        )

)

so the problem is i dont know how can i access the folder hello

what should be the path

$files = $this->DropboxApi->ls('Path);
hellosheikh
  • 2,929
  • 8
  • 49
  • 115

2 Answers2

0

Let's suppose you want to write file name myfile.extension in folder myfolder then your upload path will be:

<root>/myfolder/myfile.extension

then your endpoint url to upload file will be:

https://api-content.dropbox.com/1/files_put/dropbox/myfolder/myfile.extension

In case of download you first need to send request to endpoint:

https://api.dropbox.com/1/media/dropbox/myfolder/myfile.extension

In response you will get json like: {"url":"here is downloadable link"}

To see contents/details in folder, endpoint will be:

https://api.dropbox.com/1/metadata/dropbox/hello?list=true

Ashwani
  • 3,463
  • 1
  • 24
  • 31
  • according to my situation what it should be ?? – hellosheikh Sep 08 '13 at 08:51
  • sorry it was the first time i am integrating dropbox with php ...at this time i just want to read the directory – hellosheikh Sep 08 '13 at 08:51
  • means you need details of file in "hello" folder? @hellosheikh – Ashwani Sep 08 '13 at 08:53
  • yup exactly ..because at the moment i just want to check whether i can access it or not .. – hellosheikh Sep 08 '13 at 08:53
  • @hellosheikh see answer. you endpoint will be `https://api.dropbox.com/1/metadata/dropbox/hello?list=true` – Ashwani Sep 08 '13 at 08:57
  • so should i do this $this->DropboxApi->ls(metadata/dropbox/hello?list=true); i have to pass path here ... rest is assured by plugin itself.. actually i am working on a cakephp.. so i want to know what path do i write in braces – hellosheikh Sep 08 '13 at 08:59
  • I would say try both: ` $this->DropboxApi->ls(metadata/dropbox/hello?list=true);` and ` $this->DropboxApi->ls(/dropbox/hello?list=true);` First one should be successful. – Ashwani Sep 08 '13 at 09:04
  • well this doesn't work as well ... this is the plugin i am using .. at the end of the page there is a details of how to show the directory may be it helps you https://github.com/shama/cakebox – hellosheikh Sep 08 '13 at 09:08
  • try: $files = $this->DropboxApi->ls('hello'); and $files = $this->DropboxApi->ls('dropbox/hello');. I am not sure about path that is start from or not. Also in above comment path must between quotes @hellosheikh – Ashwani Sep 08 '13 at 09:29
  • yup the path is starting from root and i have set the root to sandbox not dropbox .. and i have print the array too above ... – hellosheikh Sep 08 '13 at 09:32
  • 1
    If your app name is actually "hello" (seems unlikely, since someone probably took that name already?), then my guess is `$this->DropboxApi->ls('/')` or maybe `->ls('')` will list the contents of `Dropbox/Apps/hello`. Basically, the path you use is always relative to your app folder (`Apps/`). – user94559 Sep 08 '13 at 18:55
0
$folder = $dropbox->GetFiles("hello",false);

it return all the files into the hello folder(return array)

Hiren Raiyani
  • 754
  • 2
  • 12
  • 28