Compare commits
75 Commits
Author | SHA1 | Date | |
---|---|---|---|
fc2ccfae4a | |||
6e3bda752d | |||
052f857f17 | |||
f9defce223 | |||
bf82c1b95e | |||
18cad618d6 | |||
4e3f08603f | |||
7e4fec1569 | |||
4288e89283 | |||
00b04e865e | |||
0a90603c93 | |||
b41731427b | |||
532f226032 | |||
a27abbe661 | |||
d21502b068 | |||
e5d620b676 | |||
bb9787099a | |||
bb6ccfa96d | |||
cc58c840c7 | |||
a3080917d9 | |||
891bd9cf87 | |||
28a646d83d | |||
8b0f5c8364 | |||
21d222848c | |||
e8829db154 | |||
c29fa441bc | |||
de5ff64981 | |||
00e8d2cb4c | |||
061c6783d5 | |||
84bc88c168 | |||
03733610e6 | |||
809d5b5045 | |||
0afe9fe4e4 | |||
77dafb9fbc | |||
bca8c49cd1 | |||
8db0bb0d8a | |||
46f10442f9 | |||
171f6dcdc7 | |||
ff3598971c | |||
a9e72c11a3 | |||
e5833c7872 | |||
19b590362e | |||
fb53fc7cd3 | |||
8304c1f83c | |||
cd4604582d | |||
48dc88f60b | |||
a0270760e3 | |||
8233e5e5eb | |||
55aa216759 | |||
4c7ec1e41d | |||
178b6c9a41 | |||
a2ba2da073 | |||
64801c97e7 | |||
28dbd93975 | |||
e6ee45582e | |||
|
64a9e6ab90 | ||
|
d20ef28621 | ||
|
f76c1745d3 | ||
|
250c2ba736 | ||
|
858d182169 | ||
|
b469b3279d | ||
|
1c92ecbdcb | ||
|
5f1c408374 | ||
|
b0ba37da3b | ||
|
507d4f870f | ||
|
5d4c759907 | ||
|
2bcbc3277c | ||
|
25b5de72cc | ||
|
079d753a40 | ||
|
59a71a84b9 | ||
|
9ef266fb3e | ||
|
e0638f2830 | ||
|
e8da944333 | ||
|
bfc63d82ae | ||
|
e216dd4507 |
12
.drone.yml
12
.drone.yml
|
@ -1,12 +0,0 @@
|
||||||
kind: pipeline
|
|
||||||
name: default
|
|
||||||
steps:
|
|
||||||
- name: test
|
|
||||||
image: crystallang/crystal:latest-alpine
|
|
||||||
environment:
|
|
||||||
commands:
|
|
||||||
- apk --no-cache add curl
|
|
||||||
- mkdir -p /tmp/files
|
|
||||||
- make deps
|
|
||||||
- make test
|
|
||||||
- make build
|
|
1
.travis.yml
Normal file
1
.travis.yml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
language: crystal
|
39
Dockerfile
39
Dockerfile
|
@ -1,29 +1,30 @@
|
||||||
FROM alpine:edge AS builder
|
#FROM manastech/crystal
|
||||||
|
FROM greyltc/archlinux
|
||||||
|
MAINTAINER Arthur Poulet <arthur.poulet@mailoo.org>
|
||||||
|
|
||||||
# Add this directory to container as /app
|
# Install crystal
|
||||||
ADD . /build
|
RUN pacman -Syu --noprogressbar --noconfirm crystal shards llvm35 llvm35-libs clang35 base-devel libxml2
|
||||||
WORKDIR /build
|
|
||||||
|
|
||||||
# Install dependencies
|
|
||||||
RUN apk add --no-cache \
|
|
||||||
crystal shards libc-dev yaml-dev libxml2-dev zlib-dev openssl-dev curl
|
|
||||||
|
|
||||||
# Install shards
|
# Install shards
|
||||||
|
WORKDIR /usr/local
|
||||||
|
#RUN apt-get update
|
||||||
|
#RUN DEBIAN_FRONTEND=noninteractive apt-get install -y curl git libssl-dev
|
||||||
|
#RUN curl -Lo bin/shards.gz https://github.com/crystal-lang/shards/releases/download/v0.6.3/shards-0.6.3_linux_x86_64.gz; gunzip bin/shards.gz; chmod 755 bin/shards
|
||||||
|
|
||||||
|
# Add this directory to container as /app
|
||||||
|
ADD . /transfer_more
|
||||||
|
WORKDIR /transfer_more
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
RUN shards install
|
RUN shards install
|
||||||
|
|
||||||
# Build our app
|
# Build our app
|
||||||
RUN crystal build --release --warnings all src/transfer_more.cr
|
RUN crystal build --release src/transfer_more.cr
|
||||||
|
|
||||||
# Run the tests
|
# Run the tests
|
||||||
RUN mkdir /tmp/files && crystal spec
|
RUN mkdir /tmp/files
|
||||||
|
#RUN crystal spec
|
||||||
|
|
||||||
FROM alpine:edge
|
EXPOSE 3000
|
||||||
MAINTAINER Arthur Poulet <arthur.poulet@sceptique.eu>
|
|
||||||
|
|
||||||
RUN apk add --no-cache libgcc libevent libgc++ pcre2
|
ENTRYPOINT ./transfer_more --port 3000
|
||||||
|
|
||||||
WORKDIR /app
|
|
||||||
ADD ./public /app/public
|
|
||||||
COPY --from=builder /build/transfer_more ./transfer_more
|
|
||||||
|
|
||||||
ENTRYPOINT ["./transfer_more"]
|
|
||||||
|
|
11
Makefile
11
Makefile
|
@ -6,9 +6,9 @@ all: deps_opt build
|
||||||
run:
|
run:
|
||||||
crystal run src/transfer_more.cr
|
crystal run src/transfer_more.cr
|
||||||
build:
|
build:
|
||||||
crystal build src/transfer_more.cr --stats --warnings all -o $(NAME)
|
crystal build src/transfer_more.cr --stats -o $(NAME)
|
||||||
release:
|
release:
|
||||||
crystal build src/transfer_more.cr --stats --release --warnings all -o $(NAME)
|
crystal build src/transfer_more.cr --stats --release -o $(NAME)
|
||||||
test:
|
test:
|
||||||
crystal spec
|
crystal spec
|
||||||
deps:
|
deps:
|
||||||
|
@ -20,8 +20,9 @@ deps_opt:
|
||||||
doc:
|
doc:
|
||||||
crystal docs
|
crystal docs
|
||||||
install:
|
install:
|
||||||
mkdir -p $(PREFIX)/transfer-more
|
mkdir -p $(PREFIX)/bin
|
||||||
cp $(NAME) $(PREFIX)/transfer-more/
|
cp $(NAME) $(PREFIX)/bin/$(NAME)
|
||||||
cp -r public $(PREFIX)/transfer-more/
|
uninstall:
|
||||||
|
rm $(PREFIX)/bin/$(NAME)
|
||||||
|
|
||||||
.PHONY: all run build release test deps deps_update doc install uninstall
|
.PHONY: all run build release test deps deps_update doc install uninstall
|
||||||
|
|
117
README.md
117
README.md
|
@ -1,18 +1,16 @@
|
||||||
**Upstream on <https://git.sceptique.eu/Sceptique/transfer_more>**
|
|
||||||
|
|
||||||
# transfer_more
|
# transfer_more
|
||||||
|
|
||||||
Fast and lite file upload server ([transfer.sh](https://transfer.sh/) clone).
|
Fast and lite file upload server ([transfer.sh](https://transfer.sh/) clone).
|
||||||
|
|
||||||
![screenshot](https://raw.githubusercontent.com/Nephos/transfer_more/master/sample.png)
|
![screenshot](https://screenshots.firefoxusercontent.com/images/191ebbd9-a5ea-4fe9-ab8c-d896f59ea08c.png)
|
||||||
|
|
||||||
- It's a simple online file sharing.
|
- It's a simple online file sharing.
|
||||||
- Files older than 7 days are destroyed (configurable).
|
- Files older than 7 days are destroyed (configurable).
|
||||||
- Recognize shebangs, magic numbers, ...
|
- Recognize shebangs, magic numbers, ...
|
||||||
|
|
||||||
## Installation [![Build Status](https://drone.sceptique.eu/api/badges/Sceptique/transfer_more/status.svg)](https://drone.sceptique.eu/Sceptique/transfer_more)
|
## Installation [![travis](https://travis-ci.org/Nephos/transfer_more.svg)](https://travis-ci.org/Nephos/transfer_more)
|
||||||
|
|
||||||
Compatible crystal v1.9.2
|
Compatible crystal v0.27.0
|
||||||
|
|
||||||
### From source
|
### From source
|
||||||
|
|
||||||
|
@ -22,70 +20,12 @@ make test # run unit test
|
||||||
make doc # build the documentation
|
make doc # build the documentation
|
||||||
```
|
```
|
||||||
|
|
||||||
### From AUR with yay (or yaourt etc.)
|
### From AUR with yaourt
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
yay -S transfer-more
|
yaourt -S transfer-more
|
||||||
```
|
```
|
||||||
|
|
||||||
### As a systemd service
|
|
||||||
|
|
||||||
[Unit]
|
|
||||||
Description=Tranfer more file sharing
|
|
||||||
Documentation=https://wiki.archlinux.org/index.php/Transfer-more
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
ExecStart=/usr/share/transfer-more/transfer-more --port 10003 --bind 127.0.0.1
|
|
||||||
Restart=on-failure
|
|
||||||
RestartSec=5
|
|
||||||
Environment="TRANSFER_SSL_ENABLED=true"
|
|
||||||
WorkingDirectory=/usr/share/transfer-more/
|
|
||||||
|
|
||||||
# Hardening
|
|
||||||
MemoryDenyWriteExecute=true
|
|
||||||
SystemCallArchitectures=native
|
|
||||||
CapabilityBoundingSet=
|
|
||||||
NoNewPrivileges=true
|
|
||||||
RemoveIPC=true
|
|
||||||
LockPersonality=true
|
|
||||||
|
|
||||||
ProtectControlGroups=true
|
|
||||||
ProtectKernelTunables=true
|
|
||||||
ProtectKernelModules=true
|
|
||||||
ProtectKernelLogs=true
|
|
||||||
ProtectClock=true
|
|
||||||
ProtectHostname=true
|
|
||||||
ProtectProc=noaccess
|
|
||||||
|
|
||||||
RestrictRealtime=true
|
|
||||||
RestrictSUIDSGID=true
|
|
||||||
RestrictNamespaces=true
|
|
||||||
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
|
|
||||||
|
|
||||||
ProtectSystem=full
|
|
||||||
ProtectHome=true
|
|
||||||
PrivateDevices=true
|
|
||||||
PrivateTmp=true
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=default.target
|
|
||||||
|
|
||||||
### Behind a nginx proxy
|
|
||||||
|
|
||||||
You should configure your nginx with `/etc/nginx/servers-enabled/transfer-more.conf`:
|
|
||||||
|
|
||||||
server {
|
|
||||||
listen 443 ssl;
|
|
||||||
server_name your.sub.domain;
|
|
||||||
client_max_body_size 1G;
|
|
||||||
proxy_set_header Host $host;
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
location / {
|
|
||||||
proxy_pass http://localhost:3000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
### Run the Server
|
### Run the Server
|
||||||
|
@ -94,11 +34,8 @@ You should configure your nginx with `/etc/nginx/servers-enabled/transfer-more.c
|
||||||
export TRANSFER_SSL_ENABLED=true # true if the ssl is enabled, any other string is false
|
export TRANSFER_SSL_ENABLED=true # true if the ssl is enabled, any other string is false
|
||||||
export TRANSFER_BASE_STORAGE="/tmp" # where the files will be kept
|
export TRANSFER_BASE_STORAGE="/tmp" # where the files will be kept
|
||||||
export TRANSFER_SECURE_SIZE=4 # how much characters to identify a file
|
export TRANSFER_SECURE_SIZE=4 # how much characters to identify a file
|
||||||
export TRANSFER_STORAGE_DAYS=7 # how much time the files are kept
|
export TRANSFER_STORRAGE_DAYS=7 # how much time the files are kept
|
||||||
export TRANSFER_TIME_FORMAT="%y%m%d%H"
|
export TRANSFER_TIME_FORMAT="%y%m%d%H"
|
||||||
export TRANSFER_HOST_PORT="localhost:3000" # in pinciple it is auto solved using the http headers, optional
|
|
||||||
export TRANSFER_MORE_FOOTER="Something <strong>important</strong> on the bottom" # replace the default footer
|
|
||||||
export TRANSFER_MORE_TITLE="MyName upload" # replace the default title
|
|
||||||
./transfer_more
|
./transfer_more
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -114,50 +51,32 @@ export TRANSFER_MORE_TITLE="MyName upload"
|
||||||
curl --progress-bar --upload-file file.mp4 http://domain/name.mp4
|
curl --progress-bar --upload-file file.mp4 http://domain/name.mp4
|
||||||
```
|
```
|
||||||
|
|
||||||
### Inside a Docker container
|
### Inside a docker
|
||||||
|
|
||||||
```sh
|
If you are using docker-compose:
|
||||||
docker build -t transfer_more . && docker run -p 3000:3000 transfer_more
|
|
||||||
```
|
|
||||||
|
|
||||||
Or with docker-compose:
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
docker-compose build && docker-compose up
|
docker-compose build && docker-compose up
|
||||||
```
|
```
|
||||||
|
|
||||||
### [ShareX](https://github.com/ShareX) template
|
Else, you can do:
|
||||||
|
|
||||||
```json
|
```sh
|
||||||
{
|
docker build -t transfer_more . && docker run transfer_more
|
||||||
"Name": "Sceptique",
|
|
||||||
"DestinationType": "ImageUploader, TextUploader, FileUploader, URLShortener",
|
|
||||||
"RequestURL": "https://up.sceptique.eu/",
|
|
||||||
"FileFormName": "file",
|
|
||||||
"Headers": {
|
|
||||||
"User-Agent": "curl"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
For now I don't have much plan expanding the feature of it, as it fulfills all my needs.
|
TODO: Write development instructions here
|
||||||
|
|
||||||
I will keep updating with each crystal new release.
|
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Feel free to propose new feature anyway, we can just put them behind feature flag if it's overkill.
|
1. Fork it ( <https://github.com/Nephos/transfer_more/fork> )
|
||||||
|
2. Create your feature branch (git checkout -b my-new-feature)
|
||||||
Review your own coding style as possible.
|
3. Commit your changes (git commit -am 'Add some feature')
|
||||||
|
4. Push to the branch (git push origin my-new-feature)
|
||||||
Do not try to include external CI in the upstream, I don't want big centralized service of the GAFAM as possible.
|
5. Create a new Pull Request
|
||||||
|
|
||||||
You can either propose a patch in an issue or open a merge request on <https://git.sceptique.eu/Sceptique/transfer_more/fork>.
|
|
||||||
|
|
||||||
You can propose it on github if you want, but git.sceptique.eu accept github OAuth so it's very quick to setup and it's my prefered way.
|
|
||||||
|
|
||||||
## Contributors
|
## Contributors
|
||||||
|
|
||||||
- [Sceptique](https://git.sceptique.eu/Sceptique) Arthur Poulet - creator, maintainer
|
- [Nephos](https://github.com/Nephos) Arthur Poulet - creator, maintainer
|
||||||
|
|
|
@ -1,102 +0,0 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
||||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
|
||||||
|
|
||||||
<svg
|
|
||||||
width="210mm"
|
|
||||||
height="297mm"
|
|
||||||
viewBox="0 0 210 297"
|
|
||||||
version="1.1"
|
|
||||||
id="svg5"
|
|
||||||
inkscape:version="1.2 (dc2aedaf03, 2022-05-15)"
|
|
||||||
sodipodi:docname="carré.svg"
|
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
||||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg">
|
|
||||||
<sodipodi:namedview
|
|
||||||
id="namedview7"
|
|
||||||
pagecolor="#505050"
|
|
||||||
bordercolor="#eeeeee"
|
|
||||||
borderopacity="1"
|
|
||||||
inkscape:showpageshadow="0"
|
|
||||||
inkscape:pageopacity="0"
|
|
||||||
inkscape:pagecheckerboard="0"
|
|
||||||
inkscape:deskcolor="#505050"
|
|
||||||
inkscape:document-units="mm"
|
|
||||||
showgrid="false"
|
|
||||||
inkscape:zoom="1.4142136"
|
|
||||||
inkscape:cx="210.71782"
|
|
||||||
inkscape:cy="277.18586"
|
|
||||||
inkscape:window-width="1920"
|
|
||||||
inkscape:window-height="1003"
|
|
||||||
inkscape:window-x="0"
|
|
||||||
inkscape:window-y="0"
|
|
||||||
inkscape:window-maximized="1"
|
|
||||||
inkscape:current-layer="layer1">
|
|
||||||
<inkscape:grid
|
|
||||||
type="xygrid"
|
|
||||||
id="grid2791" />
|
|
||||||
</sodipodi:namedview>
|
|
||||||
<defs
|
|
||||||
id="defs2" />
|
|
||||||
<g
|
|
||||||
inkscape:label="Calque 1"
|
|
||||||
inkscape:groupmode="layer"
|
|
||||||
id="layer1">
|
|
||||||
<rect
|
|
||||||
style="fill:#85b5bb;fill-opacity:1;stroke-width:2.86198"
|
|
||||||
id="rect165"
|
|
||||||
width="100"
|
|
||||||
height="100"
|
|
||||||
x="51.59375"
|
|
||||||
y="34.395832"
|
|
||||||
ry="0" />
|
|
||||||
<rect
|
|
||||||
style="fill:#e3d7f4;fill-opacity:1;stroke-width:0.198284"
|
|
||||||
id="rect2559-2-2"
|
|
||||||
width="25"
|
|
||||||
height="25"
|
|
||||||
x="89.09375"
|
|
||||||
y="96.895828" />
|
|
||||||
<g
|
|
||||||
id="g3324"
|
|
||||||
transform="translate(0.07217726,-2.5000051)">
|
|
||||||
<path
|
|
||||||
sodipodi:type="star"
|
|
||||||
style="fill:#e3d7f4;fill-opacity:1;stroke-width:0.264583"
|
|
||||||
id="path2665-6"
|
|
||||||
inkscape:flatsided="true"
|
|
||||||
sodipodi:sides="3"
|
|
||||||
sodipodi:cx="79.323067"
|
|
||||||
sodipodi:cy="58.415363"
|
|
||||||
sodipodi:r1="33.237694"
|
|
||||||
sodipodi:r2="16.618849"
|
|
||||||
sodipodi:arg1="0.5281275"
|
|
||||||
sodipodi:arg2="1.5753251"
|
|
||||||
inkscape:rounded="0"
|
|
||||||
inkscape:randomized="0"
|
|
||||||
d="M 108.0322,75.164397 50.463413,74.903682 79.473591,25.17801 Z"
|
|
||||||
inkscape:transform-center-x="0.024065192"
|
|
||||||
inkscape:transform-center-y="-5.8292997"
|
|
||||||
transform="matrix(0.86851499,-0.00296818,0.00248553,0.70188644,32.507167,46.96568)" />
|
|
||||||
<path
|
|
||||||
sodipodi:type="star"
|
|
||||||
style="fill:#e3d7f4;fill-opacity:1;stroke-width:0.264583"
|
|
||||||
id="path2665-6-9"
|
|
||||||
inkscape:flatsided="true"
|
|
||||||
sodipodi:sides="3"
|
|
||||||
sodipodi:cx="79.323067"
|
|
||||||
sodipodi:cy="58.415363"
|
|
||||||
sodipodi:r1="33.237694"
|
|
||||||
sodipodi:r2="16.618849"
|
|
||||||
sodipodi:arg1="0.5281275"
|
|
||||||
sodipodi:arg2="1.5753251"
|
|
||||||
inkscape:rounded="0"
|
|
||||||
inkscape:randomized="0"
|
|
||||||
d="M 108.0322,75.164397 50.463413,74.903682 79.473591,25.17801 Z"
|
|
||||||
inkscape:transform-center-x="0.024065192"
|
|
||||||
inkscape:transform-center-y="-5.8292997"
|
|
||||||
transform="matrix(0.86851499,-0.00296818,0.00248553,0.70188644,32.507165,29.45962)" />
|
|
||||||
</g>
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
Before Width: | Height: | Size: 3.2 KiB |
Binary file not shown.
Before Width: | Height: | Size: 17 KiB |
BIN
public/images/kemal.png
Normal file
BIN
public/images/kemal.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
BIN
sample.png
BIN
sample.png
Binary file not shown.
Before Width: | Height: | Size: 99 KiB |
22
shard.lock
22
shard.lock
|
@ -1,18 +1,18 @@
|
||||||
version: 2.0
|
version: 1.0
|
||||||
shards:
|
shards:
|
||||||
backtracer:
|
|
||||||
git: https://github.com/sija/backtracer.cr.git
|
|
||||||
version: 1.2.2
|
|
||||||
|
|
||||||
exception_page:
|
exception_page:
|
||||||
git: https://github.com/crystal-loot/exception_page.git
|
github: crystal-loot/exception_page
|
||||||
version: 0.3.0
|
version: 0.1.1
|
||||||
|
|
||||||
kemal:
|
kemal:
|
||||||
git: https://github.com/sdogruyol/kemal.git
|
github: sdogruyol/kemal
|
||||||
version: 1.3.0
|
commit: 482b4a6e7dc3be7a0352fc6b8ee8108fe4cb1105
|
||||||
|
|
||||||
|
kilt:
|
||||||
|
github: jeromegn/kilt
|
||||||
|
version: 0.4.0
|
||||||
|
|
||||||
radix:
|
radix:
|
||||||
git: https://github.com/luislavena/radix.git
|
github: luislavena/radix
|
||||||
version: 0.4.1
|
version: 0.3.8
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
name: transfer_more
|
name: transfer_more
|
||||||
version: 0.5.9
|
version: 0.5.0
|
||||||
|
|
||||||
authors:
|
authors:
|
||||||
- Arthur Poulet <arthur.poulet@sceptique.eu>
|
- Arthur Poulet <arthur.poulet@mailoo.org>
|
||||||
|
|
||||||
license: GPL-3.0
|
license: GPL-3.0
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
kemal:
|
kemal:
|
||||||
github: sdogruyol/kemal
|
github: sdogruyol/kemal
|
||||||
version: ~> 1.3
|
branch: master
|
||||||
|
|
7
src/public/css/bootstrap.min.css
vendored
Normal file
7
src/public/css/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
src/public/images/kemal.png
Normal file
BIN
src/public/images/kemal.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
|
@ -1,11 +1,13 @@
|
||||||
require "kemal"
|
require "kemal"
|
||||||
require "./transfer_more/*"
|
require "./transfer_more/*"
|
||||||
|
|
||||||
# static_headers do |response, filepath, filestat|
|
static_headers do |response, filepath, filestat|
|
||||||
# response.headers.add("Access-Control-Allow-Origin", "*")
|
if filepath =~ /\.html$/
|
||||||
# response.headers.add("Content-Size", filestat.size.to_s)
|
response.headers.add("Access-Control-Allow-Origin", "*")
|
||||||
# end
|
end
|
||||||
# serve_static true
|
response.headers.add("Content-Size", filestat.size.to_s)
|
||||||
|
end
|
||||||
|
serve_static true
|
||||||
|
|
||||||
# TODO: proper directory check
|
# TODO: proper directory check
|
||||||
Dir.mkdir(TransferMore.storage("files")) rescue nil
|
Dir.mkdir(TransferMore.storage("files")) rescue nil
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
module TransferMore
|
module TransferMore
|
||||||
SSL_ENABLED = ENV["TRANSFER_SSL_ENABLED"]?.to_s.downcase == "true"
|
SSL_ENABLED = ENV["TRANSFER_SSL_ENABLED"]?.to_s.downcase == "true"
|
||||||
BASE_STORAGE = ENV["TRANSFER_BASE_STORAGE"]? || "/tmp"
|
BASE_STORAGE = ENV["TRANSFER_BASE_STORAGE"]? || "/tmp"
|
||||||
HOST_PORT = ENV["TRANSFER_HOST_PORT"]? || "localhost:3000"
|
|
||||||
SECURE_SIZE = Int32.new(ENV["TRANSFER_SECURE_SIZE"]? || 4)
|
SECURE_SIZE = Int32.new(ENV["TRANSFER_SECURE_SIZE"]? || 4)
|
||||||
STORAGE_DAYS = Int32.new(ENV["TRANSFER_STORAGE_DAYS"]? || 7)
|
STORAGE_DAYS = Int32.new(ENV["TRANSFER_STORAGE_DAYS"]? || 7)
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
module TransferMore
|
module TransferMore
|
||||||
def self.purge(duration, verbose = true)
|
def self.purge(duration, verbose = true)
|
||||||
t_from = Time.local - duration
|
t_from = Time.now - duration
|
||||||
puts "[PURGE] Start (#{t_from})" if verbose
|
puts "[PURGE] Start (#{t_from})" if verbose
|
||||||
Dir.entries(storage "files").select do |dir|
|
Dir.entries(storage "files").select do |dir|
|
||||||
t_current = Time.parse(dir, TransferMore::TIME_FORMAT, location: Time::Location.load_local) rescue next
|
t_current = Time.parse!("#{dir}00", TransferMore::TIME_FORMAT) rescue next
|
||||||
r = t_current < t_from
|
r = t_current < t_from
|
||||||
end.each do |dir|
|
end.each do |dir|
|
||||||
spawn do
|
spawn do
|
||||||
|
@ -23,9 +23,9 @@ module TransferMore
|
||||||
puts "[REMOVE] #{subdir}/#{file}" if verbose
|
puts "[REMOVE] #{subdir}/#{file}" if verbose
|
||||||
File.delete("#{subdir}/#{file}")
|
File.delete("#{subdir}/#{file}")
|
||||||
end
|
end
|
||||||
Dir.delete(subdir)
|
Dir.rmdir(subdir)
|
||||||
end
|
end
|
||||||
Dir.delete(storage "files/#{dir}")
|
Dir.rmdir(storage "files/#{dir}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,8 +4,7 @@ module TransferMore
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.base_url(env)
|
def self.base_url(env)
|
||||||
scheme = Kemal.config.ssl || SSL_ENABLED ? "https://" : "http://"
|
scheme =
|
||||||
host_port = env.request.headers["Host"]? || HOST_PORT
|
"http#{Kemal.config.ssl || SSL_ENABLED ? 's' : nil}://#{(env.request.host_with_port || "localhost:3000")}"
|
||||||
"#{scheme}#{host_port}"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,7 +2,7 @@ require "random/secure"
|
||||||
|
|
||||||
private def get_upload_infos(filename : String)
|
private def get_upload_infos(filename : String)
|
||||||
file_name = filename.downcase
|
file_name = filename.downcase
|
||||||
dir = Time.local.to_s(TransferMore::TIME_FORMAT) + "/" + Random::Secure.hex(TransferMore::SECURE_SIZE) + (ENV["TRANSFER_MORE_CHRISTMAS"]? == "true" ? "/\u{1F384}" : "")
|
dir = Time.now.to_s(TransferMore::TIME_FORMAT) + "/" + Random::Secure.hex(TransferMore::SECURE_SIZE) + (ENV["TRANSFER_MORE_CHRISTMAS"]? == "true" ? "/\u{1F384}" : "")
|
||||||
Dir.mkdir_p TransferMore.storage("files/#{dir}")
|
Dir.mkdir_p TransferMore.storage("files/#{dir}")
|
||||||
visible_path = "#{dir}/#{file_name}"
|
visible_path = "#{dir}/#{file_name}"
|
||||||
file_path = TransferMore.storage("files/#{visible_path}")
|
file_path = TransferMore.storage("files/#{visible_path}")
|
||||||
|
@ -13,7 +13,7 @@ private def upload(env, name_of_upload, io_to_copy)
|
||||||
begin
|
begin
|
||||||
file_name, dir, visible_path, file_path = get_upload_infos name_of_upload
|
file_name, dir, visible_path, file_path = get_upload_infos name_of_upload
|
||||||
File.open(file_path, "w") { |f| IO.copy(io_to_copy, f) }
|
File.open(file_path, "w") { |f| IO.copy(io_to_copy, f) }
|
||||||
TransferMore.base_url(env) + "/f/" + visible_path
|
TransferMore.base_url(env) + "/" + visible_path
|
||||||
rescue err
|
rescue err
|
||||||
env.response.status_code = 500
|
env.response.status_code = 500
|
||||||
"Error 500: #{err}"
|
"Error 500: #{err}"
|
||||||
|
@ -73,7 +73,7 @@ post "/" do |env|
|
||||||
parseAndUpload(env)
|
parseAndUpload(env)
|
||||||
end
|
end
|
||||||
|
|
||||||
get "/f/:part1/:part2/:file_name" do |env|
|
get "/:part1/:part2/:file_name" do |env|
|
||||||
file_name = env.params.url["file_name"].to_s.downcase
|
file_name = env.params.url["file_name"].to_s.downcase
|
||||||
path = TransferMore.storage("files") + "/" + env.params.url["part1"] + "/" + env.params.url["part2"] + "/" + file_name
|
path = TransferMore.storage("files") + "/" + env.params.url["part1"] + "/" + env.params.url["part2"] + "/" + file_name
|
||||||
begin
|
begin
|
||||||
|
|
|
@ -1,64 +1,22 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<title>upload with kemal</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||||
<title><%= ENV.fetch("TRANSFER_MORE_TITLE", "File upload") %></title>
|
<!-- <link rel="stylesheet" href="/css/bootstrap.min.css" /> -->
|
||||||
<link rel="stylesheet" href="/css/bootstrap.min.css" />
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous" />
|
||||||
<!-- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous" /> -->
|
|
||||||
<!-- <link rel="stylesheet" href="//octicons.github.com/components/octicons/octicons/octicons.css"> -->
|
<!-- <link rel="stylesheet" href="//octicons.github.com/components/octicons/octicons/octicons.css"> -->
|
||||||
<!-- <script src="/js/main.js"></script> -->
|
<!-- <script src="/js/main.js"></script> -->
|
||||||
<!-- <script src="/js/dropzone.js"></script> -->
|
<!-- <script src="/js/dropzone.js"></script> -->
|
||||||
<link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon">
|
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
body {
|
body { text-align:center;font-family:helvetica,arial;font-size:22px;color:#888;margin:20px;}
|
||||||
text-align: center;
|
a { color:#66b;text-decoration:none; }
|
||||||
font-family: Helvetica, Arial;
|
#c {margin:0 auto;width:500px;text-align:left}
|
||||||
font-size: 22px;
|
|
||||||
color: #888;
|
|
||||||
margin-top: 20px;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #66b;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
#c {
|
|
||||||
margin: 0 auto;
|
|
||||||
width: 500px;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
.dropzone {
|
|
||||||
font-weight: bold;
|
|
||||||
text-align: center;
|
|
||||||
padding: 1em 0;
|
|
||||||
margin: 1em auto;
|
|
||||||
color: #555;
|
|
||||||
border: 2px dashed #555;
|
|
||||||
border-radius: 6px;
|
|
||||||
cursor: default;
|
|
||||||
height: 400px;
|
|
||||||
max-width: 400px;
|
|
||||||
background-color: rgba(250, 166, 180, 0.5);
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-position: bottom;
|
|
||||||
}
|
|
||||||
#dropzone.hover {
|
|
||||||
color: #eaa
|
|
||||||
border-color: #eaa;
|
|
||||||
border-style: solid;
|
|
||||||
box-shadow: inset 0 4px 4px #888;
|
|
||||||
}
|
|
||||||
footer {
|
|
||||||
width: 100%;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
padding: 1em;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h2><%= ENV.fetch("TRANSFER_MORE_TITLE", "File upload") %></h2>
|
<h2>transfer.sh with kemal</h2>
|
||||||
<% if !file_url.empty? %>
|
<% if !file_url.empty? %>
|
||||||
<div class="alert alert-success">
|
<div class="alert alert-success">
|
||||||
<p>Upload url: <a href="<%= file_url %>"><%= file_url %></a></p>
|
<p>Upload url: <a href="<%= file_url %>"><%= file_url %></a></p>
|
||||||
|
@ -74,19 +32,22 @@
|
||||||
|
|
||||||
<form method="POST" action="/" enctype="multipart/form-data">
|
<form method="POST" action="/" enctype="multipart/form-data">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="dropzone-bg">
|
<div class="col-lg-10">
|
||||||
<input name="commit" value="Upload" class="btn btn-primary" type="submit">
|
<input name="commit" value="Upload" class="btn btn-primary" type="submit">
|
||||||
<input class="form-control dropzone" name="file" id="file" type="file" required>Drop files</input>
|
<input class="btn btn-default" name="file" id="file" type="file">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<footer>
|
<!-- <img src="/images/kemal.png"> -->
|
||||||
<span>
|
<img src="https://kemalcr.com/img/kemal.png">
|
||||||
<%= ENV.fetch("TRANSFER_MORE_FOOTER", "built by <a href=\"https://git.sceptique.eu/Sceptique\">Sceptique</a>, powered with <a href=\"http://kemalcr.com/\">kemal</a>") %>
|
|
||||||
|
<footer style="position:fixed;bottom:0px;padding:60px;">
|
||||||
|
<span style="position:fixed;left:10%">
|
||||||
|
built by <a href="https://github.com/Nephos/">Nephos</a> with <a href="http://kemalcr.com/">kemal</a>
|
||||||
</span>
|
</span>
|
||||||
<span>
|
<span style="position:fixed;right:10%">
|
||||||
<a href="https://git.sceptique.eu/Sceptique/transfer_more">Fork or patch me</a>
|
<a href="https://github.com/Nephos/transfer_more">Fork me</a>
|
||||||
</span>
|
</span>
|
||||||
</footer>
|
</footer>
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user