OfficeDev / Office-365-SDK-for-Android

Microsoft Services SDKs for Android produced by MS Open Tech.
https://dev.office.com/android
Other
224 stars 74 forks source link

How to list files under a folder? #88

Closed forlayo closed 9 years ago

forlayo commented 9 years ago

Hello Office 365 SDK pals,

I'm using Office-365-SDK for Android ( https://github.com/OfficeDev/Office-365-SDK-for-Android ), I've been looking on all SDK examples (https://msdn.microsoft.com/en-us/office/office365/howto/starter-projects-and-code-samples) and also I've been looking into SDK source code directly but I'm not able to figure how to list files under a folder; all examples does only file list under root folder.

On Office365 REST API I can see clearly that there's a call for this pourpose ( https://msdn.microsoft.com/office/office365/APi/files-rest-operations#FolderoperationsListfoldercontentsREST ) but on this SDK I didn't found a way to create the same call.

My actual code is the very same than the one on SDK code snippets ( https://github.com/OfficeDev/O365-Android-Snippets/blob/master/app/src/main/java/com/microsoft/office365/snippetapp/Snippets/FileFolderSnippets.java ) on call "getFilesAndFolders". It list properly files and folder under root, but I haven't a way to list files and folder under a concrete folder, so I cannot create a file explorer :(.

Thanks in advance! Regards.

Also posted on StackOverflow -> http://stackoverflow.com/questions/30864766/office-365-sdk-for-android-how-to-list-files-under-a-folder

marcote commented 9 years ago

Hi @forlayo

I don't think you can do it with a one-liner, but this might work:

//retrieve the folder (as item)             
Item item = client.getFiles().getOperations().getByPath("foo/path").get();
//get the folder, and get the children 
client.getFiles().getById(item.getId()).asFolder().getChildren().read();      

can you try it please?

forlayo commented 9 years ago

@marcote It works!!

Also.. do you know a way to create public direct download link to a file ?

Thanks a lot pal :).

marcote commented 9 years ago

Glad it works! Regarding your question, no idea. The SDK only surfaces the operations allowed in the ODATA metadata, and I haven't seen anything like that there.

forlayo commented 9 years ago

@marcote Thanks a lot one more time; do you now we're can I ask my question ? I mean into Microsoft support or Microsoft ecosystem, to see if there's a way to achieve it or almost do a feature request :)

marcote commented 9 years ago

@joshgav ,can you help @forlayo pointing him into the right direction?

joshgav commented 9 years ago

@rgregg may be able to help - is there a way to create a public link to a file in OneDrive for Business?

ksheode-zz commented 9 years ago

We are doing the work to make the download API a pre-authenticated i.e. public URL and this update should be available world-wide by end-July.

Satyaranjan commented 9 years ago

I am Using your code but I can not get my answer.it shows null point and controller do not enter into that function. Can any one help me.

marcote commented 9 years ago

@satyaranjan sorry, I don't understand. Can you tell us what are you trying to achieve?

thekindJose commented 8 years ago

@ksheode - Hi, any news regarding @forlayo question about public links support??? Thx!

thekindJose commented 8 years ago

@ksheode @marcote @rgregg @joshgav - could any of you please answer the previous question? Thanks in advance.

rgregg commented 8 years ago

There isn't a way to get a public link to a OneDrive for Business file using this SDK / Files API v1.0. If you use the OneDrive SDK for Android or the Microsoft Graph SDK you can use the createLink method to create a public link. However, this capability can be disabled by an administrator, so it may not work for all users/tenants.