From b49d926d7a0b30bb2e66b8de3515516a165fcae6 Mon Sep 17 00:00:00 2001 From: richard-dds Date: Thu, 15 Aug 2019 14:10:28 -0400 Subject: [PATCH 1/5] Both uploader impelementations should return same response --- js/lib/upload.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/lib/upload.js b/js/lib/upload.js index 4a300b32..17e0b095 100644 --- a/js/lib/upload.js +++ b/js/lib/upload.js @@ -32,9 +32,9 @@ class AzureUploader { options, function(err, result) { if (err) { - reject(err) + resolve({ok: false}) } else { - resolve(result) + resolve({ok: true}) } } ) From 7f477ec0345de246d69e32e2e77fc464e20215a6 Mon Sep 17 00:00:00 2001 From: richard-dds Date: Thu, 15 Aug 2019 14:47:19 -0400 Subject: [PATCH 2/5] Fix "request entity too large" when uploading TO PDF Do this by setting disabled="true" on the file input element after selecting the file, and re-enabling it if the file is removed. This prevents the file from actually being sent to the server, since we're not using it there anyway. --- js/components/upload_input.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/js/components/upload_input.js b/js/components/upload_input.js index 273c1d20..6a1db083 100644 --- a/js/components/upload_input.js +++ b/js/components/upload_input.js @@ -64,12 +64,12 @@ export default { methods: { addAttachment: async function(e) { const file = e.target.files[0] - const response = await this.uploader.upload(file, this.objectName) if (response.ok) { this.attachment = e.target.value this.$refs.attachmentFilename.value = file.name this.$refs.attachmentObjectName.value = this.objectName + this.$refs.attachmentInput.disabled = true } else { this.showErrors = true this.uploadError = true @@ -89,6 +89,7 @@ export default { this.attachment = null if (this.$refs.attachmentInput) { this.$refs.attachmentInput.value = null + this.$refs.attachmentInput.disabled = false } this.showErrors = false this.uploadError = false From db73a12e9510d867cc94421b9e9ee76c1c5d46f4 Mon Sep 17 00:00:00 2001 From: richard-dds Date: Fri, 16 Aug 2019 13:30:03 -0400 Subject: [PATCH 3/5] Limit size of uploaded files --- js/components/upload_input.js | 23 ++++++++++++++++++----- templates/components/upload_input.html | 3 +++ translations.yaml | 1 + 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/js/components/upload_input.js b/js/components/upload_input.js index 6a1db083..a7ef694e 100644 --- a/js/components/upload_input.js +++ b/js/components/upload_input.js @@ -46,9 +46,9 @@ export default { return { hasInitialData: !!this.initialData, attachment: this.initialData || null, - showErrors: this.initialErrors, changed: false, - uploadError: null, + uploadError: false, + sizeError: false, } }, @@ -63,15 +63,22 @@ export default { methods: { addAttachment: async function(e) { + this.clearErrors() + const file = e.target.files[0] + if (file.size > 64000000) { + this.sizeError = true + return + } + const response = await this.uploader.upload(file, this.objectName) + if (response.ok) { this.attachment = e.target.value this.$refs.attachmentFilename.value = file.name this.$refs.attachmentObjectName.value = this.objectName this.$refs.attachmentInput.disabled = true } else { - this.showErrors = true this.uploadError = true } @@ -91,8 +98,7 @@ export default { this.$refs.attachmentInput.value = null this.$refs.attachmentInput.disabled = false } - this.showErrors = false - this.uploadError = false + this.clearErrors() this.changed = true emitEvent('field-change', this, { @@ -101,6 +107,10 @@ export default { watch: this.watch, }) }, + clearErrors: function() { + this.uploadError = false + this.sizeError = false + } }, computed: { @@ -115,5 +125,8 @@ export default { hideInput: function() { return this.hasInitialData && !this.changed }, + showErrors: function() { + return (!this.changed && this.initialErrors) || this.uploadError || this.sizeError + } }, } diff --git a/templates/components/upload_input.html b/templates/components/upload_input.html index a56cb0bf..a261ea21 100644 --- a/templates/components/upload_input.html +++ b/templates/components/upload_input.html @@ -46,6 +46,9 @@ + {% for error, error_messages in field.errors.items() %} {{error_messages[0]}} {% endfor %} diff --git a/translations.yaml b/translations.yaml index 1e13a8f9..7937bb96 100644 --- a/translations.yaml +++ b/translations.yaml @@ -156,6 +156,7 @@ forms: length_error: Filename may be no longer than 100 characters. task_order: upload_error: There was an error uploading your file. Please try again. If you encounter repeated problems uploading this file, please contact CCPO. + size_error: The file you have selected is too large. Please choose a file no larger than 64MB. app_migration: both: 'Yes, migrating from both an on-premise data center and another cloud provider' cloud: 'Yes, migrating from another cloud provider' From 9b7186c94f4886c5f19aabaaa999276a8d8cf1b1 Mon Sep 17 00:00:00 2001 From: richard-dds Date: Fri, 16 Aug 2019 13:49:50 -0400 Subject: [PATCH 4/5] Formatting --- js/components/upload_input.js | 10 +++++++--- js/lib/upload.js | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/js/components/upload_input.js b/js/components/upload_input.js index a7ef694e..edf01450 100644 --- a/js/components/upload_input.js +++ b/js/components/upload_input.js @@ -110,7 +110,7 @@ export default { clearErrors: function() { this.uploadError = false this.sizeError = false - } + }, }, computed: { @@ -126,7 +126,11 @@ export default { return this.hasInitialData && !this.changed }, showErrors: function() { - return (!this.changed && this.initialErrors) || this.uploadError || this.sizeError - } + return ( + (!this.changed && this.initialErrors) || + this.uploadError || + this.sizeError + ) + }, }, } diff --git a/js/lib/upload.js b/js/lib/upload.js index 17e0b095..ff85ab4a 100644 --- a/js/lib/upload.js +++ b/js/lib/upload.js @@ -32,9 +32,9 @@ class AzureUploader { options, function(err, result) { if (err) { - resolve({ok: false}) + resolve({ ok: false }) } else { - resolve({ok: true}) + resolve({ ok: true }) } } ) From 64b2f206cbc05b7470500929168a4f703c11c424 Mon Sep 17 00:00:00 2001 From: richard-dds Date: Mon, 19 Aug 2019 10:14:42 -0400 Subject: [PATCH 5/5] Update the copy displaying the PDF size limit --- translations.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translations.yaml b/translations.yaml index 7937bb96..238d97fc 100644 --- a/translations.yaml +++ b/translations.yaml @@ -383,7 +383,7 @@ task_orders: pop_start: 'Period of Performance (PoP) start date' review_button: Review task order supporting_docs_header: Upload your supporting documentation - supporting_docs_size_limit: Your file may not exceed 1MB + supporting_docs_size_limit: Your file may not exceed 64MB supporting_docs_text: Upload a single PDF containing all relevant information. step_5: title: Confirm Signature