B4J Question Google Drive Upload Example

rpalik

Member
Licensed User
Longtime User
Hi.

Is it possible to download from somewhere a working example for B4J or B4X with a demonstration of uploading a file to Google Drive?

Don't send me any links where it is not possible to download a working example, nor to any theoretical stupidity on the forum. I really don't have time for that. I'm a .NET MAUI programmer, I use B4X occasionally, so I want to see a working program.
This is not a toxic question, please don't write toxic answers. ❤️
 
Last edited:

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Is it possible to download from somewhere a working example for B4J or B4X with a demonstration of uploading a file to Google Drive?
Short answer: No

Don't send me any links where it is not possible to download a working example, nor to any theoretical stupidity on the forum. I really don't have time for that. I'm a .NET MAUI programmer, I use B4X occasionally, so I want to see a working program.
Long answer: Nooooo
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
I'm sorry but I only know theoretical stupidity. Since you are a NET MAUI programmer you don't need B4X to develop cross-platform.

I am a B4X developer and occasionally I develop with Visual Studio 2022, if you have a working code I will translate it into B4X,
But you have to put the code and please that it works. But if you search the forum you will find several examples and I believe and you will waste less time
 
Last edited:
Upvote 3

LucaMs

Expert
Licensed User
Longtime User
I like stupid answers so much; or, rather, I too much like WRITING stupid answers 😁

1679763337225.png


Perplexity B4J code (not checked/tested, of course)
B4X:
Sub UploadFileToDrive(filePath As String, fileName As String, mimeType As String)
    ' Step 1: Authenticate the request
    Dim authUrl As String = "https://accounts.google.com/o/oauth2/token"
    Dim authParams As Map
    authParams.Initialize
    authParams.Put("code", "YOUR_AUTHORIZATION_CODE")
    authParams.Put("client_id", "YOUR_CLIENT_ID")
    authParams.Put("client_secret", "YOUR_CLIENT_SECRET")
    authParams.Put("redirect_uri", "urn:ietf:wg:oauth:2.0:oob")
    authParams.Put("grant_type", "authorization_code")
    Dim authResponse As String = HttpUtils2.ExecuteHttpPost(authUrl, authParams)
    Dim accessToken As String = Regex.Matcher("access_token"":""(.+?)""", authResponse).Group(1)

    ' Step 2: Upload the file
    Dim uploadUrl As String = "https://www.googleapis.com/upload/drive/v3/files?uploadType=media"
    Dim uploadHeaders As Map
    uploadHeaders.Initialize
    uploadHeaders.Put("Authorization", "Bearer " & accessToken)
    uploadHeaders.Put("Content-Type", mimeType)
    Dim uploadResponse As String = HttpUtils2.ExecuteHttpRequest("POST", uploadUrl, Null, uploadHeaders, File.ReadAllBytes(filePath))
    Log(uploadResponse)
End Sub
 
Upvote 0

rpalik

Member
Licensed User
Longtime User
I like stupid answers so much; or, rather, I too much like WRITING stupid answers 😁



Perplexity B4J code (not checked/tested, of course)
.....
Thank you for trying, but...

What's so incomprehensible about the question is that I want a link to the code. I really don't want some code snippets. People please learn to read and answer in a way that helps people. Thank youuuu.❤️
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
The answers are always adequate to the questions.

If you refer to technical explanations as stupid, it will certainly irritate those who would have liked to help you create the code yourself.

You just want a source to copy, modify or study... maybe a different way to ask would have given you the answer you were looking for.

People have to learn to ask politely, since then it's not a must to offer a stranger a ready and working source.
But you would have gotten someone to devote an hour of their time to help you if you asked the right way
 
Upvote 0

amorosik

Expert
Licensed User
Hi.

Is it possible to download from somewhere a working example for B4J or B4X with a demonstration of uploading a file to Google Drive?

Don't send me any links where it is not possible to download a working example, nor to any theoretical stupidity on the forum. I really don't have time for that. I'm a .NET MAUI programmer, I use B4X occasionally, so I want to see a working program.
This is not a toxic question, please don't write toxic answers. ❤️

I am also very interested
If you find something good, please kindly try it and let us know
 
Upvote 0

rpalik

Member
Licensed User
Longtime User
Vatte a fa' 'na passeggiata, che già mi stai sulle palle!

How can I translate that? I don't know! Trying Google Translator:
Go take a walk, you're already pissing me off!

You can't program, can you? Come back from your walk and learn.🤣
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Hi.

Is it possible to download from somewhere a working example for B4J or B4X with a demonstration of uploading a file to Google Drive?

Don't send me any links where it is not possible to download a working example, nor to any theoretical stupidity on the forum. I really don't have time for that. I'm a .NET MAUI programmer, I use B4X occasionally, so I want to see a working program.
This is not a toxic question, please don't write toxic answers. ❤️
That was your question, rudely asked; it didn't deserve a decent answer.

I repeat: I hope Erel reads the whole thing well and bans you.

Goodbye
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
I think you are misinterpreting things. Here many know how to do it, and it shows that there are many examples on the forum developed by different users. (if you search a little you'll find them as well)

The fact that nobody helps you is not related to ego or because they don't know how, but rather your attitude has annoyed.

This is a community try to respect the members and everyone will be happy to help
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
WOW! looks like Forum engine is helping you here, @rpalik

I just saw this below this thread
firefox_OXDiaPGryE.png

But you are right, that some may or may not work as you want.
Actually the problem is many experts here use g-drive upload in their large projects but it is very very difficult for them to make a working sample from it for your requirement.

If you are ready to donate/pay then I think few members may give their valuable time in lieu of it. But again you have to request for it.
Rest is on you.
 
Upvote 0

Derek Johnson

Active Member
Licensed User
Longtime User
That's interesting. I hadn't come across the Perplexity AI before. The website says that it quotes the sources used in the answer which is a really useful feature if you are talking about code (or anything else really) so that you can do further research. I hope that my digression doesn't annoy the OP. 😂
 
Upvote 0
Top