- This image was flagged as potentially NSFW. Unfortunately, due to the UK's - Online Safety Act, we cannot handle explicit content. Please defer to using - Imgur or another image storage platform who have the resources to deal with - idiotic laws. -
-- The image you attempted to upload has not been stored. -
-or…
Or drag and drop an image here.
- PNG, JPEG, GIF or WebP, up to 8 MiB. All uploads are converted to PNGs. + Static PNG, JPEG, GIF or WebP, up to 8 MiB. All uploads are converted to + PNGs.
+ {blocked && ( + <> ++ This image was flagged as potentially NSFW. Unfortunately, due to + the UK's Online Safety Act, we cannot handle explicit content. + Please defer to using Imgur or another image storage platform who + have the resources to deal with idiotic laws. +
++ The image you attempted to upload has not been stored. +
+ > + )} {uploading &&Uploading image…
} )} diff --git a/src/web/image_uploads.rs b/src/web/image_uploads.rs index 327b24e..379d69b 100644 --- a/src/web/image_uploads.rs +++ b/src/web/image_uploads.rs @@ -84,6 +84,7 @@ impl ImageUploadService { { return Err("S3_PUBLIC_URL must be an HTTP(S) base URL of at most 400 bytes".into()); } + let endpoint = env::var("S3_ENDPOINT").ok().filter(|value| !value.trim().is_empty()); let region = match &endpoint { Some(endpoint) => { @@ -91,11 +92,13 @@ impl ImageUploadService { } None => values[1].parse()?, }; + let credentials = Credentials::new(Some(&values[2]), Some(&values[3]), None, None, None)?; let mut bucket = Bucket::new(&values[0], region, credentials)?; if endpoint.is_some() { bucket = bucket.with_path_style(); } + bucket.set_request_timeout(Some(std::time::Duration::from_secs(30))); let model = if check_nsfw { Some(nsfw::create_model(MODEL_BYTES)?) @@ -156,17 +159,21 @@ fn decode_image(bytes: &[u8]) -> Result