Spaces:
Running
Running
Update app.R
Browse files
app.R
CHANGED
|
@@ -1989,19 +1989,20 @@ observeEvent(input$upload_hf_btn, {
|
|
| 1989 |
arrow::write_parquet(combined, tmp)
|
| 1990 |
|
| 1991 |
result <- tryCatch({
|
| 1992 |
-
resp <- httr::
|
| 1993 |
paste0("https://huggingface.co/api/datasets/", repo_id, "/upload/main/", filename),
|
| 1994 |
httr::add_headers(
|
| 1995 |
-
Authorization = paste("Bearer", hf_token)
|
| 1996 |
-
`Content-Type` = "application/octet-stream"
|
| 1997 |
),
|
| 1998 |
-
body = httr::upload_file(tmp)
|
|
|
|
| 1999 |
)
|
| 2000 |
|
| 2001 |
if (httr::status_code(resp) %in% c(200, 201)) {
|
| 2002 |
paste0("Done! ", nrow(combined), " total rows in dataset.")
|
| 2003 |
} else {
|
| 2004 |
-
|
|
|
|
| 2005 |
}
|
| 2006 |
}, error = function(e) {
|
| 2007 |
paste("Upload error:", e$message)
|
|
|
|
| 1989 |
arrow::write_parquet(combined, tmp)
|
| 1990 |
|
| 1991 |
result <- tryCatch({
|
| 1992 |
+
resp <- httr::POST(
|
| 1993 |
paste0("https://huggingface.co/api/datasets/", repo_id, "/upload/main/", filename),
|
| 1994 |
httr::add_headers(
|
| 1995 |
+
Authorization = paste("Bearer", hf_token)
|
|
|
|
| 1996 |
),
|
| 1997 |
+
body = list(file = httr::upload_file(tmp)),
|
| 1998 |
+
encode = "multipart"
|
| 1999 |
)
|
| 2000 |
|
| 2001 |
if (httr::status_code(resp) %in% c(200, 201)) {
|
| 2002 |
paste0("Done! ", nrow(combined), " total rows in dataset.")
|
| 2003 |
} else {
|
| 2004 |
+
resp_text <- httr::content(resp, as = "text", encoding = "UTF-8")
|
| 2005 |
+
paste0("Upload failed: ", httr::status_code(resp), " - ", resp_text)
|
| 2006 |
}
|
| 2007 |
}, error = function(e) {
|
| 2008 |
paste("Upload error:", e$message)
|