B4J Question How to upload file with http

jinyistudio

Well-Known Member
Licensed User
Longtime User
following is ok

B4X:
' send image file by line notify
Sub lineNotify3(token As String, imageUrl As String)
    Dim url As StringBuilder
    url.Initialize
    url.Append($"https://notify-api.line.me/api/notify"$)
    '
    Dim fd As MultipartFileData
    fd.Initialize
    fd.KeyName="imageFile"
    fd.Dir = $"${File.DirApp}/www/linenotify/images"$
    fd.FileName = imageUrl
    fd.ContentType = "image/png"
    '
    Dim data As Map
    data.Initialize
    data.Put("message","123")
    '
    Dim job1 As HttpJob
    job1.Initialize("image", Me)  
    job1.PostMultipart(url.ToString,data,Array(fd))
    job1.GetRequest.SetHeader("Content-Type","multipart/form-data")
    job1.GetRequest.SetHeader("Authorization",$"Bearer ${token}"$)
End Sub

 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…