【发布时间】:2021-06-12 06:11:39
【问题描述】:
我正在尝试使用 rapiclient 以编程方式更新我的 Figshare 存储库。 在answer 到question 之后,我设法通过以下方式进行身份验证并查看我的存储库:
library(rapiclient)
library(httr)
# figshare repo id
id = 3761562
fs_api <- get_api("https://docs.figshare.com/swagger.json")
header <- c(Authorization = sprintf("token %s", Sys.getenv("RFIGSHARE_PAT")))
fs_api <- list(operations = get_operations(fs_api, header),
schemas = get_schemas(fs_api))
reply <- fs_api$operations$article_files(id)
我还设法使用以下方法删除了一个文件:
fs_api$operations$private_article_file_delete(article_id = id, file_id = F)
现在,我想将一个新文件上传到存储库。我似乎需要两种方法:
fs_api$operations$private_article_upload_initiate
fs_api$operations$private_article_upload_complete
但我不理解文档。根据fs_api$operations$private_article_upload_initiate帮助:
> fs_api$operations$private_article_upload_initiate
private_article_upload_initiate
Initiate Upload
Description:
Initiate new file upload within the article. Either use link to
provide only an existing file that will not be uploaded on figshare
or use the other 3 parameters(md5, name, size)
Parameters:
link (string)
Url for an existing file that will not be uploaded on figshare
md5 (string)
MD5 sum pre computed on the client side
name (string)
File name including the extension; can be omitted only for linked
files.
size (integer)
File size in bytes; can be omitted only for linked files.
“不会上传到 Figshare 的文件”是什么意思?如何使用 API 上传本地文件~/foo.txt?
fs_api$operations$private_article_upload_initiate(link='~/foo.txt')
返回 HTTP 400。
【问题讨论】: