Add multipart
This commit is contained in:
parent
704cddc6e7
commit
a069b318bc
@ -2,20 +2,28 @@ image: archlinux
|
|||||||
packages:
|
packages:
|
||||||
- nodejs
|
- nodejs
|
||||||
- rustup
|
- rustup
|
||||||
|
- yarn
|
||||||
sources:
|
sources:
|
||||||
- https://git.sr.ht/~tsumanu/jirs
|
- https://git.sr.ht/~tsumanu/jirs
|
||||||
environment:
|
environment:
|
||||||
deploy: adrian.wozniak@ita-prog.pl
|
deploy: adrian.wozniak@ita-prog.pl
|
||||||
|
NODE_ENV: production
|
||||||
|
DEBUG: false
|
||||||
|
JIRS_CLIENT_PORT: 80
|
||||||
|
JIRS_CLIENT_BIND: jirs.ita-prog.pl
|
||||||
|
JIRS_SERVER_PORT: 80
|
||||||
|
JIRS_SERVER_BIND: jirs.ita-prog.pl
|
||||||
secrets:
|
secrets:
|
||||||
- 7ebab768-e5e4-4c9d-ba57-ec41a72c5665
|
- 7ebab768-e5e4-4c9d-ba57-ec41a72c5665
|
||||||
tasks:
|
tasks:
|
||||||
- setup: |
|
- setup: |
|
||||||
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
|
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sudo sh
|
||||||
- test: |
|
- test: |
|
||||||
cd jirs/jirs-client
|
cd ~/jirs/jirs-client
|
||||||
wasm-pack test --node
|
wasm-pack test --node
|
||||||
- build: |
|
- build: |
|
||||||
cd jirs/jirs-client
|
cd ~/jirs/jirs-client
|
||||||
wasm-pack build --release
|
yarn
|
||||||
|
yarn webpack-cli -p --config ./webpack.config.js
|
||||||
- deploy: |
|
- deploy: |
|
||||||
cd jirs
|
cd ~/jirs
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
image: shepmaster/rust-nightly
|
image: archlinux
|
||||||
packages:
|
packages:
|
||||||
- postgresql
|
- postgresql
|
||||||
|
- rustup
|
||||||
sources:
|
sources:
|
||||||
- https://git.sr.ht/~tsumanu/jirs
|
- https://git.sr.ht/~tsumanu/jirs
|
||||||
environment:
|
environment:
|
||||||
@ -8,8 +9,14 @@ environment:
|
|||||||
secrets:
|
secrets:
|
||||||
- 7ebab768-e5e4-4c9d-ba57-ec41a72c5665
|
- 7ebab768-e5e4-4c9d-ba57-ec41a72c5665
|
||||||
tasks:
|
tasks:
|
||||||
|
- build_config: |
|
||||||
|
cd jirs/jirs-server
|
||||||
|
echo 'concurrency = 2' >> db.test.toml
|
||||||
|
echo 'database_url = "postgres://postgres@localhost:5432/jirs_test"' >> db.test.toml
|
||||||
- setup: |
|
- setup: |
|
||||||
sudo systemctl start postgresql
|
sudo systemctl start postgresql
|
||||||
|
rustup toolchain install nightly
|
||||||
|
rustup default nightly
|
||||||
cargo install diesel_cli --no-default-features --features postgres
|
cargo install diesel_cli --no-default-features --features postgres
|
||||||
cd jirs/jirs-server
|
cd jirs/jirs-server
|
||||||
diesel migration run
|
diesel migration run
|
||||||
|
29
README.md
29
README.md
@ -1,5 +1,9 @@
|
|||||||
# A simplified Jira clone built with seed.rs and actix
|
# A simplified Jira clone built with seed.rs and actix
|
||||||
|
|
||||||
|
[![builds.sr.ht status](https://builds.sr.ht/~tsumanu/jirs.sr.ht.svg)](https://builds.sr.ht/~tsumanu/jirs.sr.ht?)
|
||||||
|
|
||||||
|
https://git.sr.ht/~tsumanu/jirs
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
* Actor based asynchronous backend
|
* Actor based asynchronous backend
|
||||||
@ -7,6 +11,31 @@
|
|||||||
|
|
||||||
## How to run it
|
## How to run it
|
||||||
|
|
||||||
|
### Config files
|
||||||
|
|
||||||
|
```toml
|
||||||
|
# web.toml
|
||||||
|
concurrency = 2
|
||||||
|
port = "5000"
|
||||||
|
bind = "0.0.0.0"
|
||||||
|
ssl = false
|
||||||
|
```
|
||||||
|
|
||||||
|
```toml
|
||||||
|
# db.toml
|
||||||
|
concurrency = 2
|
||||||
|
database_url = "postgres://postgres@localhost:5432/jirs"
|
||||||
|
```
|
||||||
|
|
||||||
|
```toml
|
||||||
|
# mail.toml
|
||||||
|
concurrency = 2
|
||||||
|
user = "apikey"
|
||||||
|
pass = "YOUR-TOKEN"
|
||||||
|
host = "smtp.sendgrid.net"
|
||||||
|
from = "contact@jirs.pl"
|
||||||
|
```
|
||||||
|
|
||||||
### Local variables
|
### Local variables
|
||||||
|
|
||||||
Within `jirs` directory place `.env` file with following content
|
Within `jirs` directory place `.env` file with following content
|
||||||
|
@ -1,7 +1,25 @@
|
|||||||
|
use actix_multipart::Multipart;
|
||||||
use actix_web::{get, post, web, HttpResponse, Responder};
|
use actix_web::{get, post, web, HttpResponse, Responder};
|
||||||
|
use futures::{StreamExt, TryStreamExt};
|
||||||
|
use std::io::Write;
|
||||||
|
|
||||||
#[post("/")]
|
#[post("/")]
|
||||||
async fn upload() -> impl Responder {
|
async fn upload(mut payload: Multipart) -> impl Responder {
|
||||||
|
while let Ok(Some(mut field)) = payload.try_next().await {
|
||||||
|
let content_type = field.content_disposition().unwrap();
|
||||||
|
let filename = content_type.get_filename().unwrap();
|
||||||
|
let filepath = format!("./tmp/{}", filename);
|
||||||
|
// File::create is blocking operation, use threadpool
|
||||||
|
let mut f = web::block(|| std::fs::File::create(filepath))
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
// Field in turn is stream of *Bytes* object
|
||||||
|
while let Some(chunk) = field.next().await {
|
||||||
|
let data = chunk.unwrap();
|
||||||
|
// filesystem operations are blocking, we have to use threadpool
|
||||||
|
f = web::block(move || f.write_all(&data).map(|_| f)).await?;
|
||||||
|
}
|
||||||
|
}
|
||||||
HttpResponse::Ok().json("")
|
HttpResponse::Ok().json("")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user