feat: no_transform
This commit is contained in:
parent
a85dbf88b9
commit
a9a9ba6328
@ -6,7 +6,8 @@ Image hosting service
|
|||||||
- [NIP-96 Support](https://github.com/nostr-protocol/nips/blob/master/96.md)
|
- [NIP-96 Support](https://github.com/nostr-protocol/nips/blob/master/96.md)
|
||||||
- [Blossom Support](https://github.com/hzrd149/blossom/blob/master/buds/bud-01.md)
|
- [Blossom Support](https://github.com/hzrd149/blossom/blob/master/buds/bud-01.md)
|
||||||
- Image compression to WebP (FFMPEG, NIP-96)
|
- Image compression to WebP (FFMPEG, NIP-96)
|
||||||
- Blurhash calculation (NIP-96)
|
- Blurhash calculation (NIP-96 only)
|
||||||
|
- AI image labeling ([ViT224](https://huggingface.co/google/vit-base-patch16-224))
|
||||||
|
|
||||||
## Planned
|
## Planned
|
||||||
- Torrent seed V2
|
- Torrent seed V2
|
||||||
|
@ -117,6 +117,7 @@ struct Nip96Form<'r> {
|
|||||||
caption: Option<&'r str>,
|
caption: Option<&'r str>,
|
||||||
media_type: Option<&'r str>,
|
media_type: Option<&'r str>,
|
||||||
content_type: Option<&'r str>,
|
content_type: Option<&'r str>,
|
||||||
|
no_transform: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn nip96_routes() -> Vec<Route> {
|
pub fn nip96_routes() -> Vec<Route> {
|
||||||
@ -161,6 +162,9 @@ async fn upload(
|
|||||||
return Nip96Response::error("File too large");
|
return Nip96Response::error("File too large");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if form.size > settings.max_upload_bytes {
|
||||||
|
return Nip96Response::error("File too large");
|
||||||
|
}
|
||||||
let file = match form.file.open().await {
|
let file = match form.file.open().await {
|
||||||
Ok(f) => f,
|
Ok(f) => f,
|
||||||
Err(e) => return Nip96Response::error(&format!("Could not open file: {}", e)),
|
Err(e) => return Nip96Response::error(&format!("Could not open file: {}", e)),
|
||||||
@ -175,7 +179,7 @@ async fn upload(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
match fs
|
match fs
|
||||||
.put(file, mime_type, true)
|
.put(file, mime_type, !form.no_transform.unwrap_or(false))
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(blob) => {
|
Ok(blob) => {
|
||||||
|
@ -7,10 +7,26 @@
|
|||||||
html {
|
html {
|
||||||
background-color: black;
|
background-color: black;
|
||||||
color: white;
|
color: white;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 400;
|
||||||
|
font-family: Arial, serif;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flex {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flex-col {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gap-2 {
|
||||||
|
gap: 0.5rem;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<script>
|
<script>
|
||||||
async function uploadFiles(e) {
|
async function uploadFiles(e) {
|
||||||
|
try {
|
||||||
const input = document.querySelector("#file");
|
const input = document.querySelector("#file");
|
||||||
const file = input.files[0];
|
const file = input.files[0];
|
||||||
console.debug(file);
|
console.debug(file);
|
||||||
@ -20,6 +36,7 @@
|
|||||||
fd.append("caption", file.name);
|
fd.append("caption", file.name);
|
||||||
fd.append("media_type", file.type);
|
fd.append("media_type", file.type);
|
||||||
fd.append("file", file);
|
fd.append("file", file);
|
||||||
|
fd.append("no_transform", document.querySelector("#no_transform").checked.toString())
|
||||||
|
|
||||||
const auth_event = await window.nostr.signEvent({
|
const auth_event = await window.nostr.signEvent({
|
||||||
kind: 27235,
|
kind: 27235,
|
||||||
@ -46,6 +63,11 @@
|
|||||||
document.querySelector("#log").append(text);
|
document.querySelector("#log").append(text);
|
||||||
}
|
}
|
||||||
document.querySelector("#log").append("\n");
|
document.querySelector("#log").append("\n");
|
||||||
|
} catch (ex) {
|
||||||
|
if (ex instanceof Error) {
|
||||||
|
alert(ex.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
@ -53,20 +75,26 @@
|
|||||||
<h1>
|
<h1>
|
||||||
Welcome to void_cat_rs
|
Welcome to void_cat_rs
|
||||||
</h1>
|
</h1>
|
||||||
|
<div class="flex flex-col gap-2">
|
||||||
<div>
|
<div>
|
||||||
<p>
|
|
||||||
Upload a file using NIP-96
|
Upload a file using NIP-96
|
||||||
</p>
|
</div>
|
||||||
<small>
|
<div style="color: #ff8383;">
|
||||||
You must have a nostr extension for this to work
|
You must have a nostr extension for this to work
|
||||||
</small>
|
</div>
|
||||||
|
<input type="file" id="file">
|
||||||
|
<div>
|
||||||
|
<input type="checkbox" id="no_transform">
|
||||||
|
<label for="no_transform">
|
||||||
|
Disable compression (images)
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<input type="file" id="file">
|
|
||||||
<button type="submit" onclick="uploadFiles(event)">
|
<button type="submit" onclick="uploadFiles(event)">
|
||||||
Upload
|
Upload
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<pre id="log"></pre>
|
<pre id="log"></pre>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
Reference in New Issue
Block a user