Android Question Upload file to web, without user intervention

vecino

Well-Known Member
Licensed User
Longtime User
Hi, I've searched the forums, but I have not found what I want.
I need to upload files to a website, but without user intervention.
I do not know if it is possible.
Thank you.
 

Sandman

Expert
Licensed User
Longtime User
It's kind of a broad subject, and you're very vague, so it's difficult to give good help. But here's some bullet points for you to work with:

Doing things without user intervention
Look into using a service, the forum is full of info about this.

Upload files to a website
Your best options are probably to either use an api on the server that accepts your uploads, or set up a public ftp server. I'm fairly certain that the forum contains info on uploading files using ftp, and it's fairly simple doing the same using a simple api on the server. Either way you need to have a lot of cooperation of the server.

I can't really give better help than this without a detailed description on what it is that you're trying to accomplish.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I do not know if it is possible.
The correct answer is given.
It's possible.
I guess this is not what you want? Think over how you ask questions.
Do not ask yes/no questions if you do not expect to get YES or NO as answer.

As written by @Sandman your question is really vague.

Where do you want to upload files to?
- To your server?
- To your customers server?
- To any server?
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Sorry, I just reviewed my initial question and I have omitted data.
What I need is to upload text files using http. No ftp.
And it's my server web.
Thank you.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
I know it's not an excuse, but today I forgot my glasses at home and I'm using the smartphone almost blindly.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
What I need is to upload text files using http. No ftp.
You need to have a server component running on the server which accepts fileuploads. A B4J app, a PHP Script.

Do a Job.Postmultipart using okhttputils2 to upload files to the endpoint accepting fileuploads.

Basically the code must be something like

B4X:
    Dim j As HttpJob
    j.Initialize("", Me)
    Dim m As Map = CreateMap("additionalfield":"additional data")
    
    Dim filelist As List  ' List holding all files to Upload
    filelist.Initialize
    
    Dim fd As MultipartFileData ' Create a MultipartFileData for each file to upload
    fd.Initialize
    fd.Dir = File.DirAssets
    fd.FileName = "testfiletoupload.txt"
    fd.ContentType = "Text/Plain"
    fd.KeyName = "Testfile"
    
    filelist.Add(fd) ' and add the MultipartFileData to the list
    
    j.PostMultipart("http://domain.com/uploadendpoint.php",m,filelist) ' Upload the files and also giving the additional Values (m Map) to the uploadendpoint
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        Log(j.GetString)
    End If
    j.Release
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Hello, and sorry for the time elapsed.
I had to buy a new glasses, I can not find the old glasses.
I have not been able to work until now.

CreateMap("additionalfield":"additional data")

Is additionalfield a variable?
Is additional data the name of the file?
Thank you.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Is additionalfield a variable?
it is the key additionalfield which is sended.
like the get value in a url ("domain.com/index.php?additionalfield=additional data")
Is additional data the name of the file?
no
B4X:
Dim fd As MultipartFileData ' Create a MultipartFileData for each file to upload
    fd.Initialize
    fd.Dir = File.DirAssets ' Path on device
    fd.FileName = "testfiletoupload.txt" ' filename on device to upload
    fd.ContentType = "Text/Plain"
    fd.KeyName = "Testfile" ' the key used to identify
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…