@gradio/utils
Advanced tools
Comparing version 0.5.0 to 0.5.1
# @gradio/utils | ||
## 0.5.1 | ||
### Fixes | ||
- [#8737](https://github.com/gradio-app/gradio/pull/8737) [`31a876d`](https://github.com/gradio-app/gradio/commit/31a876d0274d7b74a90d30148f3e9c098f486242) - Fix `Share to community` button for images. Thanks @hannahblair! | ||
## 0.5.0 | ||
@@ -4,0 +10,0 @@ |
{ | ||
"name": "@gradio/utils", | ||
"version": "0.5.0", | ||
"version": "0.5.1", | ||
"description": "Gradio UI packages", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -34,3 +34,3 @@ import type { ActionReturn } from "svelte/action"; | ||
export async function uploadToHuggingFace( | ||
data: string, | ||
data: string | { url?: string; path?: string }, | ||
type: "base64" | "url" | ||
@@ -45,3 +45,13 @@ ): Promise<string> { | ||
if (type === "url") { | ||
const response = await fetch(data); | ||
let url: string; | ||
if (typeof data === "object" && data.url) { | ||
url = data.url; | ||
} else if (typeof data === "string") { | ||
url = data; | ||
} else { | ||
throw new Error("Invalid data format for URL type"); | ||
} | ||
const response = await fetch(url); | ||
blob = await response.blob(); | ||
@@ -51,5 +61,15 @@ contentType = response.headers.get("content-type") || ""; | ||
} else { | ||
blob = dataURLtoBlob(data); | ||
contentType = data.split(";")[0].split(":")[1]; | ||
filename = "file" + contentType.split("/")[1]; | ||
let dataurl: string; | ||
if (typeof data === "object" && data.path) { | ||
dataurl = data.path; | ||
} else if (typeof data === "string") { | ||
dataurl = data; | ||
} else { | ||
throw new Error("Invalid data format for base64 type"); | ||
} | ||
blob = dataURLtoBlob(dataurl); | ||
contentType = dataurl.split(";")[0].split(":")[1]; | ||
filename = "file." + contentType.split("/")[1]; | ||
} | ||
@@ -56,0 +76,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25126
233