Skip to content

Comments

tsv ingest fix for directupload#7124

Merged
kcondon merged 8 commits intoIQSS:developfrom
GlobalDataverseCommunityConsortium:IQSS/7122-tsv_ingest_with_directupload
Aug 12, 2020
Merged

tsv ingest fix for directupload#7124
kcondon merged 8 commits intoIQSS:developfrom
GlobalDataverseCommunityConsortium:IQSS/7122-tsv_ingest_with_directupload

Conversation

@qqmyers
Copy link
Member

@qqmyers qqmyers commented Jul 23, 2020

What this PR does / why we need it: enables ingest of .tsv files (and potentially other types) with direct upload when the browser does not supply a mimetype. The changes here invoke code to determine the mimetype from the extension and then update the mapping of tsv files to the currently required text/tsv mimetype.

Which issue(s) this PR closes:

Closes #7122

Special notes for your reviewer:

Suggestions on how to test this: setup for direct upload and try uploading a small tsv - it should ingest to produce a .tab file. Also turn on fine logging for the FileUtil class and look for "Determined type: text/tsv". - If you see this, it indicates that you are in the test case where your browser doesn't supply a mimetype for .tsv files. If you don't see this, you may need to remove any mapping for the .tsv extension from your test browser/machine (or I can slack/demo against the test server from my browser that doesn't provide a mimetype).

Does this PR introduce a user interface change? If mockups are available, please link/include them here: no

Is there a release notes update needed for this change?: no

Additional documentation:

@coveralls
Copy link

coveralls commented Jul 23, 2020

Coverage Status

Coverage increased (+0.03%) to 19.561% when pulling b3be92f on GlobalDataverseCommunityConsortium:IQSS/7122-tsv_ingest_with_directupload into c859b16 on IQSS:develop.

@sekmiller sekmiller self-assigned this Aug 7, 2020
logger.fine("Determined type: " + finalType);
} else {
//Remote file, trust supplier
finalType = suppliedContentType;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we care if the suppliedContentType is blank or null?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That should already be being caught (e.g. in the EditDatafilesPage.handleExternalUpload method) but worth a safety check here probably. And we shouldn't replace the default with a null/blank response if determineFileTypeByExtension returns null/blank.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you make that change, I'll put this into QA. Thanks!

@sekmiller sekmiller self-requested a review August 7, 2020 18:54
@sekmiller sekmiller removed their assignment Aug 7, 2020
@kcondon kcondon self-assigned this Aug 12, 2020
as in normal upload. This will replace generic types as in this issue as
well as replace text/tab-separated-value mimetypes so that tsv files get
ingested and will stop the browser supplied mimetypes for r, stata, etc.
in the same way that normal upload does.


private static File saveInputStreamInTempFile(InputStream inputStream, Long fileSizeLimit)
private static boolean useRecognizedType(String suppliedContentType, String recognizedType) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just moved and made to return a boolean, no logic changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ingest of tsv fails in direct upload

5 participants