B4A Class Dropbox API V2. All HTTP! All using httputils2

Danbicky

Member
Licensed User
Don this is awesome. Do you pretty please have an example of using this?

My idea is to knock up a simple application that allows my students to access folders I store on drop box with lesson material in such as PDF files, word, excel etc, lesson plan over the academic year, assignment schedule etc. This would allow them to catch up with work if they miss lessons etc.

Would be gratefully appreciated if you have an example I can build from.

Thanks buddy

Dans
 

DonManfred

Expert
Licensed User
Do you pretty please have an example of using this?
See the Project in Post #1. Anything you need is there. You just need to call the Methods.
My idea is to knock up a simple application that allows my students to access folders I store on drop box with lesson material in such as PDF files
Just create a Folder in your Dropbox and create a ShareURL for it. Give the shareURL to all your students. They can access all the files inside this folder when using the link. You can use
B4X:
dbx.CreateSharedLink(path As String, shorturl As Boolean)
to create a sharedlink.

You students dont need to use my Class to access the files!

Maybe you should explain more in details what exactly you want to do.

PS: Welcome in our comunity!
 

Danbicky

Member
Licensed User
See the Project in Post #1. Anything you need is there. You just need to call the Methods.

Just create a Folder in your Dropbox and create a ShareURL for it. Give the shareURL to all your students. They can access all the files inside this folder when using the link. You can use
B4X:
dbx.CreateSharedLink(path As String, shorturl As Boolean)
to create a sharedlink.

You students dont need to use my Class to access the files!

Maybe you should explain more in details what exactly you want to do.

PS: Welcome in our comunity!
Thanks Don,

My aim is to create a student friendly application that allows them to follow the intensive lessons delivered. I lecture in advanced electronic engineering, delivering 7 different units over the academic year. Each unit has 30 delivery sessions of material taught over the period. Ideally I would like to create an app that allows the content to become visible after the lesson has been taught. This would then allow students to recap in detail prior to completing a summative assessment.

Dropbox is a good repository and very simple for me to publish material too. Any idea's on how I go about this would be brilliant, maybe you could suggest another option if Dropbox is not the ideal solution.

Big thanks again, I am really happy to become part of this great community, only of recent have I started to dabble with B4A although I do have a wealth of programming experience coding in assembler language for microcontrollers for over 20 years.

Dans
 

DonManfred

Expert
Licensed User
I lecture in advanced electronic engineering, delivering 7 different units over the academic year. Each unit has 30 delivery sessions of material taught over the period.
You are delivering an app for your students which they will use?
So basically you need to get rid of which lesson a student solved. Based on this you can give the user access to the specific file for the next lesson.

The basic logic behind this you need to build by yourself. But with dropbox you have an very very powerful "toy" in your hands. You should be able to build a solution with my class and a bit of own logic (and layout to the student which lessons are available, which ones the already solved, an so on)
Any idea's on how I go about this would be brilliant, maybe you could suggest another option if Dropbox is not the ideal solution.
Like i said above i think that Dropbox IS the right solution about the repository; you (your app) is able to get specific files and to download them for the student, showing the pdf is just calling an intent after you downloaded the file...

It´s needs a bit of "logic" to handle your special needs, yes. But you surely can use Dropbox as a good place to share documents of any type and size.

If you need help on building this solution with dropbox then please create a new Thread for this issue as it will be some discusses over there for it. I will try to help you if needed.

We should use THIS thread here for any Problems using my class.
 

Danbicky

Member
Licensed User
Don,

Awesome, I am heading in the right direction :)

Big thanks buddy, I will download your class and project and start to experiment. Good idea to start another thread based on this requirement. A big thanks for providing assistance with this, I do really think that a solution like this would help many lecturers and most importantly the students.

Kind regards

Dans
 

Danbicky

Member
Licensed User
Don,

Just a quick download and complie, I get the following error:

B4A version: 5.20
Parsing code. (0.04s)
Compiling code. Error
Error compiling program.
Error description: Unknown type: anywheresoftware.b4a.http.HttpClientWrapper.HttpUriRequestWrapper
Are you missing a library reference?
Occurred on line: 76
job.GetRequest.SetContentEncoding("text/plain")
Word: setcontentencoding

I have the OkHTTP lib

Any ideas on why it is unhappy?

Thanks Dans
 

DonManfred

Expert
Licensed User
Dropbox today released the new V2 API

Some new Methods are implemented inside the V2 (compared to the beta-2). Most of them regarding Shared folders, people who are bound to a shared folder and so on... See here for more details.

I will do an update of my Class in a few weeks... For the next three weeks i probably dont have the time to do an update ...
 

Rabbit

Member
Licensed User
Hi DonManfred,

I understand this code will allow me to intract wit the dropbox if it has been installed on the Android device?


So, If I want to access my files as login by username & password.. How I can do it?

Regards,
 

DonManfred

Expert
Licensed User
I understand this code will allow me to intract wit the dropbox if it has been installed on the Android device?
No. It communicates with DROPBOX.
So, If I want to access my files as login by username & password.
Create a app in dropbox


generate access token for this app


copy the credentials. Use these credentials with the class.
 

Mahares

Well Known Member
Licensed User
I will do an update of my Class in a few weeks... For the next three weeks i probably dont have the time to do an update ...
Eagerly anticipating your new Dropbox V2 class as the beta was very helpful. Do not let us down.
Thank you for being so reliable and essential driver of this forum.
 

DonManfred

Expert
Licensed User
I´m still working on the update.

'
' ========================
' API V2
' ========================
'
'
'users
'/get_account OK
'/get_current_account OK
'/get_space_usage OK
'/get_account_batch MISSING

'files
'/get_metadata OK
'/list_folder/longpoll MISSING
'/list_folder OK
'/list_folder/Continue OK
'/list_folder/get_latest_cursor OK
'/Download OK
'/upload_session/start OK
'/upload_session/append OK
'/upload_session/finish OK
'/Upload OK
'/Search OK
'/create_folder OK
'/Delete OK
'/permanently_delete MISSING
'/copy OK
'/move OK
'/get_thumbnail OK
'/get_preview NOT WORKING AS YET
'/list_revisions OK
'/restore MISSING
'

'sharing
'/get_shared_links OK
'/create_shared_link OK
'/revoke_shared_link OK
'/get_folder_metadata OK
'/list_folders OK
'/share_folder OK
'/update_folder_policy OK
'/unshare_folder MISSING
'/transfer_folder MISSING
'/unmount_folder MISSING
'/mount_folder MISSING
'/add_folder_member MISSING
'/check_share_job_status MISSING
'/check_job_status MISSING
'/remove_folder_member MISSING
'/update_folder_member MISSING
'/relinquish_folder_membership MISSING

' MISSING AT ALL
' /restore
' /get_account_batch
' /ListFolderLongpoll
'
' NOT WORKING:
' /get_preview
'
' ========================
' New in V0.90ß (12/04/15)
' sharing:
' ->get_shared_links
' ->create_shared_link
' ->revoke_shared_link
' ->get_folder_metadata
' ->list_folders
' ->share_folder
' ->update_folder_policy
'
' ========================
' New in V0.87ß (9/9/2015)
' - getsharedlinks(path as String)
' - CreateSharedLink(path As String, shorturl As Boolean)
 

wizard699

Active Member
Licensed User
But, in this versione, EVENT doesn't fire? I'm using UPLOAD .... but the event FILEUPLOAD doesn't fire
 

wizard699

Active Member
Licensed User
I cannot see any code you ae using. Without seeing it it is hard to give congrete answers.
It is working for me
Code:

Globals
------------
Dim dbx As DropBox


Activity_Create
-------------
dbx.Initialize(Me,"DropBox", "mytoken", False)
dbx.Upload( pathnomeDirLetture, CameraModule.fileTosend ,"/", CameraModule.fileTosend)


and then there is event ...
----------------------------

Sub DropBox_FileUpload(meta As Map)
Msgbox("Dropbox_FileUpload: "&meta,"Info")

End Sub


File UPLOAD goes ok ... and the file was send corrctly!
But event doesn't fire.


Thanks
 

DonManfred

Expert
Licensed User
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim dbx As DropBox
End Sub
Sub Activity_Create(FirstTime As Boolean)
    dbx.Initialize(Me,"DropBox","your key here",True)
    dbx.Upload(File.DirRootExternal,"overlay.png","/","overlay.png")
End Sub
Sub DropBox_FileUpload(meta As Map)
    Log("Dropbox_FileUpload: "&meta)
  
    Dim Path As String = meta.Get("path_lower")
    Log("Path: "&Path)
    Dim rev As String = meta.Get("rev")
    Log("Rev: "&rev)
    Dim name As String = meta.Get("name")
    Log("Name: "&name)
    Dim size As Int = meta.Get("size")
    Log("FileSize: "&size)
    Dim client_modified As String = meta.Get("client_modified")
    Dim server_modified As String = meta.Get("server_modified")
    Log("ClientModified: "&client_modified)
    Log("ServerModified: "&server_modified)
End Sub
LogCat connected to: 05157df57d72d204
--------- beginning of main
--------- beginning of system
** Activity (main) Pause, UserClosed = true **
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
{"path":"/overlay.png", "mode": "overwrite"}
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
JobDone(fileupload)
RES:{"name": "overlay.png", "path_lower": "/overlay.png", "id": "id:qn6VkEYC6_gAAAAAAAAhbA", "client_modified": "2015-12-12T08:51:37Z", "server_modified": "2015-12-12T08:51:37Z", "rev": "88e411fadbd8", "size": 48945}
dbxSession=(MyMap) {name=overlay.png, path_lower=/overlay.png, id=id:qn6VkEYC6_gAAAAAAAAhbA, client_modified=2015-12-12T08:51:37Z, server_modified=2015-12-12T08:51:37Z, rev=88e411fadbd8, size=48945}
Dropbox_FileUpload: (MyMap) {name=overlay.png, path_lower=/overlay.png, id=id:qn6VkEYC6_gAAAAAAAAhbA, client_modified=2015-12-12T08:51:37Z, server_modified=2015-12-12T08:51:37Z, rev=88e411fadbd8, size=48945}
Path: /overlay.png
Rev: 88e411fadbd8
Name: overlay.png
FileSize: 48945
ClientModified: 2015-12-12T08:51:37Z
ServerModified: 2015-12-12T08:51:37Z
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
 

Attachments

DonManfred

Expert
Licensed User
as the beta was very helpful
FYI (not released as yet (still working on it))

B4X:
'
' ========================
' API V2
' ========================
'
'
'users
'/get_account                 OK
'/get_current_account  OK
'/get_space_usage         OK
'/get_account_batch      MISSING

'files
'/get_metadata               OK
'/list_folder/longpoll      MISSING
'/list_folder                      OK
'/list_folder/Continue    OK
'/list_folder/get_latest_cursor  OK
'/Download                      OK
'/upload_session/start   OK
'/upload_session/append  OK
'/upload_session/finish OK
'/Upload                            OK
'/Search                             OK
'/create_folder                 OK
'/Delete                             OK
'/permanently_delete    MISSING
'/copy                                OK
'/move                               OK
'/get_thumbnail               OK
'/get_preview                   OK
'/list_revisions                  OK
'/restore                            MISSING
'

'sharing
'/get_shared_links                            OK
'/create_shared_link                        OK
'/revoke_shared_link                       OK
'/list_folders                                      OK
'/list_folders_continue                    OK
'/get_folder_metadata                    OK
'/list_folder_members                     OK
'/list_folder_members_continue   OK
'/share_folder                                    OK
'/update_folder_policy                    OK
'/unshare_folder                               OK
'/transfer_folder                               UNTESTED
'/unmount_folder                            UNTESTED
'/mount_folder                                 UNTESTED
'/add_folder_member                     OK
'/check_share_job_status               OK
'/check_job_status                           OK
'/remove_folder_member              OK
'/update_folder_member               OK
'/relinquish_folder_membership   OK

' MISSING AT ALL
' /restore
' /get_account_batch
' /ListFolderLongpoll
'
' ========================
' New in V0.92ß (12/12/15)
' sharing:
' ->get_shared_links                        
' ->create_shared_link                    
' ->revoke_shared_link                    
' ->get_folder_metadata                    
' ->list_folders                                
' ->list_folders_continue
' ->share_folder    
' ->update_folder_policy                        
' ->unshare_folder
' ->transfer_folder
' ->unmount_folder
' ->mount_folder
' ->check_share_job_status
' ->list_folder_members
' ->list_folder_members_continue
' ->remove_folder_member
' ->relinquish_folder_membership
 
Last edited:
Top