Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

item_upload_create only posts the first file #39

Open
jordansread opened this issue Mar 6, 2015 · 6 comments
Open

item_upload_create only posts the first file #39

jordansread opened this issue Mar 6, 2015 · 6 comments
Labels

Comments

@jordansread
Copy link
Contributor

when using multi-file post

@jordansread
Copy link
Contributor Author

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?

@lawinslow
Copy link
Contributor

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.

@aappling-usgs
Copy link
Contributor

upvoting - this would be nice to have if it can be made to work.

@jordansread
Copy link
Contributor Author

👍

@sckott
Copy link
Contributor

sckott commented Sep 9, 2015

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

screen shot 2015-09-09 at 4 24 50 pm

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

@lawinslow
Copy link
Contributor

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))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants