Android Question File upload problem with HttpJob

Paul53

Member
Licensed User
Hi all,
I need to upload a large file to Google Drive and I succeeded:
B4X:
Dim h_ul As HttpJob
h_ul.Initialize("",Me)

h_ul.PostFile("https://www.googleapis.com/upload/drive/v3/files",localPath,localFilename)
h_ul.GetRequest.SetHeader("Authorization", "Bearer " & mytoken)

Wait For (h_ul) JobDone(h_ul As HttpJob)
If h_ul.Success Then
.........

but the file received from GD is "Untitled".
How can I send the file with a name?

Thanks in advance.
 

drgottjr

Expert
Licensed User
Longtime User
you'll need to look into postmultipart
you also need to know how google drive expects you to identify the files you're uploading (eg "name=...", "file=...")
 
Upvote 0

Paul53

Member
Licensed User
I had already tried this solution
B4X:
...
Dim mp As MultipartFileData
mp.Initialize
mp.Dir =localPath
mp.FileName = localFilename
mp.KeyName = "newfile"
mp.ContentType = "multipart/related"

Dim lst As List
lst.Initialize
lst.Add(mp)

j.PostMultipart("https://www.googleapis.com/upload/drive/v3/files", Null, Array(mp))
...

but I always get "ResponseError"

I upload directly to Google Drive without using PHP
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
how you described your problem in the first place was not helpful.

your implementation of postmultipart does not correspond to instructions readily available with a little googling
(including https://developers.google.com/drive/api/v3/manage-uploads).
my guess would be that's why it didn't work.
 
Upvote 0

Paul53

Member
Licensed User
Sorry but i don't know english and i use Google translate.
I hope this time to be clear.

I use this solution to send my files directly to Google Drive
GoogleDrive via REST API V3 - Small Testproject | B4X Programming Forum

and it works great for small files, but not for files over 200 Mb and I don't know why (I'm inexperienced).
So I was looking for another solution.
I tried that proposal (postmultipart) but I am not able to configure the required parameters.
I will try another solution.
Thanks anyway
 
Upvote 0
Top