radames commited on
Commit
446d1c3
1 Parent(s): 536b6c6

use .env for public uploads

Browse files
frontend/.env.development.example CHANGED
@@ -1,2 +1,3 @@
1
  PUBLIC_WS_INPAINTING="ws://0.0.0.0:7860/gradio/queue/join"
2
- PUBLIC_UPLOADS="http://0.0.0.0:7860/uploads"
 
 
1
  PUBLIC_WS_INPAINTING="ws://0.0.0.0:7860/gradio/queue/join"
2
+ PUBLIC_UPLOADS="https://d26smi9133w0oo.cloudfront.net/uploads"
3
+ PUBLIC_UPLOAD_URL="/server/uploadfile/"
frontend/.env.example CHANGED
@@ -1,2 +1,3 @@
1
  PUBLIC_WS_INPAINTING="wss://spaces.huggingface.tech/huggingface-projects/stable-diffusion-multiplayer/gradio/queue/join"
2
- PUBLIC_UPLOADS="https://hf.space/embed/huggingface-projects/stable-diffusion-multiplayer/uploads"
 
 
1
  PUBLIC_WS_INPAINTING="wss://spaces.huggingface.tech/huggingface-projects/stable-diffusion-multiplayer/gradio/queue/join"
2
+ PUBLIC_UPLOADS="https://d26smi9133w0oo.cloudfront.net/uploads"
3
+ PUBLIC_UPLOAD_URL="/embed/huggingface-projects/stable-diffusion-multiplayer/uploadfile/"
frontend/src/lib/utils.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { dev } from '$app/environment';
2
 
3
  export function base64ToBlob(base64image: string): Promise<Blob> {
4
  return new Promise((resolve) => {
@@ -23,7 +23,6 @@ export function base64ToBlob(base64image: string): Promise<Blob> {
23
  export async function uploadImage(imagBlob: Blob, prompt: string, key: string): Promise<string> {
24
  // simple regex slugify string for file name
25
  const promptSlug = slugify(prompt);
26
- const UPLOAD_URL = dev ? '/server/uploadfile/' : '/embed/huggingface-projects/stable-diffusion-multiplayer/uploadfile/';
27
 
28
  const hash = crypto.randomUUID().split('-')[0];
29
  const fileName = `color-palette-${hash}-${promptSlug}-${key}.jpeg`;
@@ -35,7 +34,7 @@ export async function uploadImage(imagBlob: Blob, prompt: string, key: string):
35
 
36
  console.log('uploading image', file);
37
 
38
- const response = await fetch(UPLOAD_URL, {
39
  method: 'POST',
40
  body: formData
41
  });
 
1
+ import { PUBLIC_UPLOAD_URL } from '$env/static/public';
2
 
3
  export function base64ToBlob(base64image: string): Promise<Blob> {
4
  return new Promise((resolve) => {
 
23
  export async function uploadImage(imagBlob: Blob, prompt: string, key: string): Promise<string> {
24
  // simple regex slugify string for file name
25
  const promptSlug = slugify(prompt);
 
26
 
27
  const hash = crypto.randomUUID().split('-')[0];
28
  const fileName = `color-palette-${hash}-${promptSlug}-${key}.jpeg`;
 
34
 
35
  console.log('uploading image', file);
36
 
37
+ const response = await fetch(PUBLIC_UPLOAD_URL, {
38
  method: 'POST',
39
  body: formData
40
  });