Comments (9)
First make sure there is an access scope defined for the rpcd session (http://git.openwrt.org/?p=project/luci2/ui.git;a=blob;f=luci2/share/acl.d/luci2.json#l168)
File Upload
Best take a look at the old prototype code here: http://git.openwrt.org/?p=project/luci2/ui.git;a=blob;f=luci2/htdocs/luci2/view/system.upgrade.js#l128 and here: http://git.openwrt.org/?p=project/luci2/ui.git;a=blob;f=luci2/htdocs/luci2/ui.js#l123
In order to upload an arbitrary file you need to issue a POST request to /cgi-bin/luci-upload
and supply these parameters:
sessionid
- the l2-session id valuefilename
- the intended destination filepathfilemode
- the intended destination permission in octal, e.g.0600
- optionalfiledata
- the actual file data
Fields 1-3 must precede field 4 for the upload request to get accepted and the encoding must be multipart/form-data
.
Backup Download
A backup download is easy to trigger by simply issuing a POST request to /cgi-bin/luci-backup
with the sessionid
parameter set to the l2-session id.
from luci-ng.
Example for a file upload
$ echo "Hello" > /tmp/test.txt
$ md5sum /tmp/test.txt
09f7e02f1290be211da707a266f153b3 /tmp/test.txt
$ curl -k -F "sessionid=b7e17a670e5637668fa6a5c79c3f2c6e" -F "filename=/tmp/foo.txt" -F "filemode=0400" -F "filedata=@/tmp/test.txt" https://192.168.1.1/cgi-bin/luci-upload
{
"size": 6,
"checksum": "09f7e02f1290be211da707a266f153b3"
}
When you then check your router via SSH:
$ ssh [email protected]
BusyBox v1.24.1 (2016-01-24 13:30:56 CET) built-in shell (ash)
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
-----------------------------------------------------
DESIGNATED DRIVER (Bleeding Edge, r48476)
-----------------------------------------------------
* 2 oz. Orange Juice Combine all juices in a
* 2 oz. Pineapple Juice tall glass filled with
* 2 oz. Grapefruit Juice ice, stir well.
* 2 oz. Cranberry Juice
-----------------------------------------------------
root@jj:~# ls -lh /tmp/foo.txt
-r-------- 1 root root 6 Mar 18 16:09 /tmp/foo.txt
root@jj:~#
from luci-ng.
Example for a backup download
$ curl -k -F "sessionid=b7e17a670e5637668fa6a5c79c3f2c6e" https://192.168.1.1/cgi-bin/luci-backup
from luci-ng.
Hello jow,
Thanks for help.
Will try this after easter holiday
Best regards
Flo
Am 18.03.2016 4:13 nachm. schrieb "Jo-Philipp Wich" <
[email protected]>:
Example for a backup download
$ curl -k -F "sessionid=b7e17a670e5637668fa6a5c79c3f2c6e" https://192.168.1.1/cgi-bin/luci-backup
—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/jow-/luci-ng/issues/5#issuecomment-198403802
from luci-ng.
Hello Jow,
i have tested the backup as you suggest. With your curl line it is not working as expected. I always get "Backup permission denied". I think the reason is that the Content-Type was set twice first to "application/x-www-form-urlencodedand" and then "multipart/form-data" ( I have added a --verbose option to command)
My line is was to get the backup file as expected
"curl -k --data "sessionid=2dd09c999867dd6c7c9a206aec22a734" -H "Content−Type:application/x-www-form-urlencoded" https://192.168.0.50/cgi-bin/luci-backup > backup.tar.gz"
But something is already is strange because it takes a long time and after that i get "curl: (18) transfer closed with outstanding read data remaining". But the backup file is complete and not corrupted? I think curl does not recognize the end of the transmission.
Regards
Flo
from luci-ng.
Hello Jow,
I have made a backup page. To download and upload a backup. Additional it is possible to edit the file /etc/sysupgrade.conf for. I am not sure if this meets your needs. Do you want a patch or should i make a pull request?
Additionally the problem with luci-backup to download the backup file is still present i am unable to solve the issue that the download take a long time. The curl request stops with a "curl: (18) transfer closed with outstanding read data remaining". But the backup.tar.gz is not corrupted :-)
Regards
Flo
from luci-ng.
@feckert Ignore the error 18 for now, I believe its an issue around content-length/chunked encoding/http 1.1
Please do a PR for this feature!
from luci-ng.
Hello @jow- ,
i did a PR #11 for this issue. if it is integrated we should close this issue.
Regards
Flo
from luci-ng.
#11 got merged now.
from luci-ng.
Related Issues (20)
- IRC Minutes
- luci-ng blocks build HOT 2
- Luci-ng general HOT 16
- How to use the new node.js tools? HOT 1
- Why not continue to develop?
- (feat) Switch to websockets based transport for Ubus HOT 1
- (feat) Integrate legacy Luci views inside new Luci-ng app HOT 1
- What is the follow-up development plan for luci-ng? HOT 1
- (feat) ui-core: save workflow
- luci-vue HOT 1
- luci2-ui-base-2017-11-27-e439ce6 doesn't build HOT 1
- luci2-ui-base-2018-06-12 build failed on Ubuntu 18.04, Thanks HOT 1
- can ui-core be run on windows or only on openwrt? HOT 1
- What is a status of the project? HOT 3
- Add a license to the project. HOT 2
- Issues with local time
- Consider using Mithril+Tachyons for UI instead of Angular
- it's still developed ?
- luci2 build error openwrt 19.07.3 HOT 1
- Build Failed on Openwrt 19.07.7 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from luci-ng.