OwenStOnge commited on
Commit
bad9e49
·
verified ·
1 Parent(s): 56c5df2

Update app.R

Browse files
Files changed (1) hide show
  1. app.R +14 -15
app.R CHANGED
@@ -1806,25 +1806,24 @@ observeEvent(input$scrape_btn, {
1806
  gh_repo <- Sys.getenv("GITHUB_REPO")
1807
 
1808
  result <- tryCatch({
1809
- httr::POST(
1810
- paste0("https://api.github.com/repos/", gh_repo, "/actions/workflows/scrape.yml/dispatches"),
1811
  httr::add_headers(
1812
- Authorization = paste("Bearer", gh_token),
1813
- Accept = "application/vnd.github.v3+json"
1814
  ),
1815
- body = jsonlite::toJSON(list(
1816
- ref = "main",
1817
- inputs = list(
1818
- start_date = as.character(input$start_date),
1819
- end_date = as.character(input$end_date),
1820
- data_type = input$scrape_source
1821
- )
1822
- ), auto_unbox = TRUE),
1823
- encode = "raw"
1824
  )
 
 
 
 
 
 
 
 
1825
  }, error = function(e) {
1826
- scrape_status_msg(paste("Failed:", e$message))
1827
- return(NULL)
1828
  })
1829
 
1830
  if (is.null(result)) return()
 
1806
  gh_repo <- Sys.getenv("GITHUB_REPO")
1807
 
1808
  result <- tryCatch({
1809
+ resp <- httr::POST(
1810
+ paste0("https://huggingface.co/api/datasets/", repo_id, "/upload/main/", filename),
1811
  httr::add_headers(
1812
+ Authorization = paste("Bearer", hf_token)
 
1813
  ),
1814
+ body = list(file = httr::upload_file(tmp, type = "application/octet-stream")),
1815
+ encode = "multipart"
 
 
 
 
 
 
 
1816
  )
1817
+
1818
+ resp_text <- httr::content(resp, as = "text", encoding = "UTF-8")
1819
+
1820
+ if (httr::status_code(resp) %in% c(200, 201)) {
1821
+ paste0("Done! ", nrow(combined), " total rows in dataset.")
1822
+ } else {
1823
+ paste0("Upload failed: ", httr::status_code(resp), " - ", resp_text)
1824
+ }
1825
  }, error = function(e) {
1826
+ paste("Upload error:", e$message)
 
1827
  })
1828
 
1829
  if (is.null(result)) return()