Android Question Google Cloud Storage upload

Discussion in 'Android Questions' started by foakgul, Jul 8, 2019.

  1. foakgul

    foakgul Member Licensed User

    Hello all,

    What I'd like to accomplish is to simply upload a file (zip) to a bucket that I've already created on Google Cloud Storage.

    REST API URI is given as:[BUCKET_NAME]/o?uploadType=media&name=[OBJECT_NAME]

    I do understand that I need oauth2 to access the API and I'll need to use oauth2 library:

    Wait For OAuth2_AccessTokenAvailable (Success As Boolean, Token As String)
    If Success = False Then
    ToastMessageShow("Error accessing account."True)
    End If
    Dim j As HttpJob
    "", Me)
    The part I'm trying to figure out is do I use:
    -j.download2 OR

    In either case, what would be the proper full command to upload the file to my bucket? Where do I fill in access_token if I need to use postfile command?

    Thanks a lot!
  2. DonManfred

    DonManfred Expert Licensed User


    If you still want to use rest; Add a authentification header to your request.
    Dim job As HttpJob
    "https://url...."' Download, PosString, ect.
        job.GetRequest.SetHeader("Authorization","Bearer "&access_token) 'Set the header AFTER the Download/Postfile
        wait for (job) JobDone(j As HttpJob)
    If j.Success Then
    'Dim OutStream As OutputStream = File.OpenOutput(File.DirRootExternal, "Result.txt", False)
            'File.Copy2(job.GetInputStream,OutStream) ' save the file
    Log("JobError: "&job.ErrorMessage)
    End If
    End Sub
    Last edited: Jul 8, 2019
    Erel likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice