Community discussions

MikroTik App
 
User avatar
ricard2k
just joined
Topic Author
Posts: 9
Joined: Thu Oct 09, 2014 2:50 pm
Location: Madrid/spain
Contact:

HTTP put backup

Tue Jan 23, 2018 12:47 pm

I'm trying to upload backups to a central site. And of course, in 2018, FTP is not an option.

This is my script:
/tool fetch mode=https http-method=put  url="https://myS3ApiGateway.amazonaws.com/router/pepe.backup" keep-result=no http-data=[/file get pepe.backup contents ]
But I'm obtaining empty zero bytes files.

The problem is that I can't get the content of backup file:
:put  [:len [/file get pepe.backup contents ]]
0
Anybody knows how can I HTTP PUT a backup?
 
User avatar
ricard2k
just joined
Topic Author
Posts: 9
Joined: Thu Oct 09, 2014 2:50 pm
Location: Madrid/spain
Contact:

Re: HTTP put backup

Wed Jan 24, 2018 1:05 pm

After some test, I've discovered that the problem is that you can't get file contents greater than 4KBytes.

Then I have other problem: I don't know how to use a file as palyload for /tool fetch http-method=put
 
SuperJC710e
just joined
Posts: 1
Joined: Tue Feb 20, 2018 6:05 am

Re: HTTP put backup

Wed Feb 27, 2019 9:13 pm

After some test, I've discovered that the problem is that you can't get file contents greater than 4KBytes.

Then I have other problem: I don't know how to use a file as payload for /tool fetch http-method=put

Did anyone ever present a solution to this? I would like to upload a backup file to webserver (running nextcloud) using the put method. How can this be done?

A method using curl works like this (both examples with the variables defined beforehand of course):
curl -s -u ${user}:${pass} -T ${filedir}/${file} "${baseurl}/remote.php/dav/files/${user}/${savepath}/${file}"

I've tried something like this:
/tool fetch address=$address host=$address mode=https http-method=put src-path=( "$file" . ".backup" ) dst-path=( "$savepath" . "/" . "$file" . ".backup" ) user="$user" password="$pass";

(I also tried with the src-path more like the dst-path.) While it does connect, it uploads/creates a zero-byte file. How can I attach the backup file to upload it?

TIA!
 
User avatar
NetVicious
Member Candidate
Member Candidate
Posts: 128
Joined: Fri Nov 13, 2009 3:30 pm
Location: Spain

Re: HTTP put backup

Wed Sep 25, 2019 3:26 pm

After some test, I've discovered that the problem is that you can't get file contents greater than 4KBytes.

Then I have other problem: I don't know how to use a file as palyload for /tool fetch http-method=put
The file command it's which has the problem with files greater than 4KBytes. I tried it first to capture the contents of the file within the API.

It seems there it's not any other way than mode=ftp to upload files to one external server.

The /tool fetch don't accepts to upload files with http-method=put or http-method=post
 
User avatar
eworm
Forum Guru
Forum Guru
Posts: 1070
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: HTTP put backup

Fri Oct 04, 2019 12:08 am

You can use SFTP (transport over SSH) to securely upload your files.
 
User avatar
NetVicious
Member Candidate
Member Candidate
Posts: 128
Joined: Fri Nov 13, 2009 3:30 pm
Location: Spain

Re: HTTP put backup

Fri Oct 04, 2019 11:15 am

Yes I know, but it will be easier to use TFTP-upload or HTTP(s)-upload because there are lots of free components outside. For SFTP it's a bit difficult and expensive to add it to one self-made application
 
User avatar
eworm
Forum Guru
Forum Guru
Posts: 1070
Joined: Wed Oct 22, 2014 9:23 am
Location: Oberhausen, Germany
Contact:

Re: HTTP put backup

Sat Oct 05, 2019 12:17 am

All you need is a SSH server with SFTP implementation. I guess OpenSSH is used the most, but there are others. What's expensive about it?
 
User avatar
NetVicious
Member Candidate
Member Candidate
Posts: 128
Joined: Fri Nov 13, 2009 3:30 pm
Location: Spain

Re: HTTP put backup

Sat Oct 05, 2019 12:35 pm

I'm talking about embedding all in one application. I know I can use one external SFTP/SSH server, but If you want to release one application with all inside that external SSH server it's an extra.

I don't know how why it's so difficult to add http/https upload when they have the http/https protocol coded at this moment.
 
x9939781
just joined
Posts: 4
Joined: Wed Sep 16, 2020 5:01 am

Re: HTTP put backup

Sat Sep 11, 2021 7:18 pm

now only (s)ftp can do upload=yes
i need HTTP(s) put backup too~i hope fetch add this~

Who is online

Users browsing this forum: nocivo and 17 guests