item_upload_create only posts the first file
when using multi-file post
I think this is the way this service is supposed to work, as it posts a file and creates an item to contain it. Should probably only have file (instead of files) as the param. Change documentation and warn if length(file)!=1?
Ah, this is a super complicated issue.
Notes for future reference:
SB can handle multiple files for this type of upload. File upload and update and upload and create seem to be very similar endpoints. Having issues uploading multiple files may be a fluke, as I can get both to work with most files. But I can also get both to fail even with just one file. This example kills both item_append_files and item_upload_create.
OMG Why?
Must be encoding of some sort. One of the big puzzles is how much "Content-Transfer-Encoding:binary" matters in the multi-file upload. I am fairly certain I can't add that to the uploads using httr or RCurl. Furthermore, it seems to be a part of MIME protocol standards, not HTTP, as discussed here and mentioned in RFC2616 19.4.5. This may be the reason I am generally unable to add that particular header with most HTTP clients I've used.
The general pattern I've been seeing is files that are interpreted as text/plain and application/*compressed (maybe...) are uploading fine. Files that would be straight-up binary and interpreted as such fail. A weird work around seems to be taking the binary file and changing the extension to *.zip, which then works. For example, this file fails, but the same file, with *.zip, works.
upvoting - this would be nice to have if it can be made to work.
:+1:
With the current version on master, this works for me:
cat('{"foo": 8}',file = "stuff1.json")
cat('{"bar": 9}',file = "stuff2.json")
item_upload_create(user_id(), files = c("stuff1.json", "stuff2.json"))
#> [1] "55f0bfa0e4b0dacf699ead7b"
result in GUI
But doesn't work if files are in a list(), but that could be fixed easily i imagine within the helper fxn multi_file_body
This problem specifically seems to manifest if you're trying to upload non-text or hard to recognize binary files. JSON works fine, but try this on for size.
f2 = system.file('extdata/This_kills_sb_upload.sbn', package='sbtools')
f1 = system.file('extdata/This_works_new_extension.zip', package='sbtools')
item_upload_create(user_id(), files = c(f1, f2))