Merge pull request #1397 from dod-ccpo/171114893-pdf-bug
PDF download bug
This commit is contained in:
commit
da283e4615
@ -43,10 +43,12 @@ class AzureFileService(FileService):
|
|||||||
|
|
||||||
from azure.storage.common import CloudStorageAccount
|
from azure.storage.common import CloudStorageAccount
|
||||||
from azure.storage.blob import BlobSasPermissions
|
from azure.storage.blob import BlobSasPermissions
|
||||||
|
from azure.storage.blob.models import BlobPermissions
|
||||||
from azure.storage.blob.blockblobservice import BlockBlobService
|
from azure.storage.blob.blockblobservice import BlockBlobService
|
||||||
|
|
||||||
self.CloudStorageAccount = CloudStorageAccount
|
self.CloudStorageAccount = CloudStorageAccount
|
||||||
self.BlobSasPermissions = BlobSasPermissions
|
self.BlobSasPermissions = BlobSasPermissions
|
||||||
|
self.BlobPermissions = BlobPermissions
|
||||||
self.BlockBlobService = BlockBlobService
|
self.BlockBlobService = BlockBlobService
|
||||||
|
|
||||||
def get_token(self):
|
def get_token(self):
|
||||||
@ -72,20 +74,22 @@ class AzureFileService(FileService):
|
|||||||
return ({"token": sas_token}, object_name)
|
return ({"token": sas_token}, object_name)
|
||||||
|
|
||||||
def generate_download_link(self, object_name, filename):
|
def generate_download_link(self, object_name, filename):
|
||||||
account = self.CloudStorageAccount(
|
block_blob_service = self.BlockBlobService(
|
||||||
account_name=self.account_name, account_key=self.storage_key
|
account_name=self.account_name, account_key=self.storage_key
|
||||||
)
|
)
|
||||||
bbs = account.create_block_blob_service()
|
sas_token = block_blob_service.generate_blob_shared_access_signature(
|
||||||
sas_token = bbs.generate_blob_shared_access_signature(
|
container_name=self.container_name,
|
||||||
self.container_name,
|
blob_name=object_name,
|
||||||
object_name,
|
permission=self.BlobPermissions(read=True),
|
||||||
permission=self.BlobSasPermissions(read=True),
|
|
||||||
expiry=datetime.utcnow() + self.timeout,
|
expiry=datetime.utcnow() + self.timeout,
|
||||||
content_disposition=f"attachment; filename={filename}",
|
content_disposition=f"attachment; filename={filename}",
|
||||||
protocol="https",
|
protocol="https",
|
||||||
)
|
)
|
||||||
return bbs.make_blob_url(
|
return block_blob_service.make_blob_url(
|
||||||
self.container_name, object_name, protocol="https", sas_token=sas_token
|
container_name=self.container_name,
|
||||||
|
blob_name=object_name,
|
||||||
|
protocol="https",
|
||||||
|
sas_token=sas_token,
|
||||||
)
|
)
|
||||||
|
|
||||||
def download_task_order(self, object_name):
|
def download_task_order(self, object_name):
|
||||||
|
@ -17,7 +17,7 @@ export default {
|
|||||||
filename: {
|
filename: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
objectName: {
|
initialObjectName: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
initialErrors: {
|
initialErrors: {
|
||||||
@ -42,6 +42,7 @@ export default {
|
|||||||
filenameError: false,
|
filenameError: false,
|
||||||
downloadLink: '',
|
downloadLink: '',
|
||||||
fileSizeLimit: this.sizeLimit,
|
fileSizeLimit: this.sizeLimit,
|
||||||
|
objectName: this.initialObjectName,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -72,6 +73,7 @@ export default {
|
|||||||
const response = await uploader.upload(file)
|
const response = await uploader.upload(file)
|
||||||
if (uploadResponseOkay(response)) {
|
if (uploadResponseOkay(response)) {
|
||||||
this.attachment = e.target.value
|
this.attachment = e.target.value
|
||||||
|
this.objectName = uploader.objectName
|
||||||
this.$refs.attachmentFilename.value = file.name
|
this.$refs.attachmentFilename.value = file.name
|
||||||
this.$refs.attachmentObjectName.value = response.objectName
|
this.$refs.attachmentObjectName.value = response.objectName
|
||||||
this.$refs.attachmentInput.disabled = true
|
this.$refs.attachmentInput.disabled = true
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
inline-template
|
inline-template
|
||||||
{% if not field.errors %}
|
{% if not field.errors %}
|
||||||
v-bind:filename='{{ field.filename.data | tojson }}'
|
v-bind:filename='{{ field.filename.data | tojson }}'
|
||||||
v-bind:object-name='{{ field.object_name.data | tojson }}'
|
v-bind:initial-object-name='{{ field.object_name.data | tojson }}'
|
||||||
{% else %}
|
{% else %}
|
||||||
v-bind:initial-errors='true'
|
v-bind:initial-errors='true'
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -46,7 +46,7 @@
|
|||||||
v-bind:value="attachment"
|
v-bind:value="attachment"
|
||||||
type="file">
|
type="file">
|
||||||
<input type="hidden" name="{{ field.filename.name }}" id="{{ field.filename.name }}" ref="attachmentFilename">
|
<input type="hidden" name="{{ field.filename.name }}" id="{{ field.filename.name }}" ref="attachmentFilename">
|
||||||
<input type="hidden" name="{{ field.object_name.name }}" id="{{ field.object_name.name }}" ref="attachmentObjectName">
|
<input type="hidden" name="{{ field.object_name.name }}" id="{{ field.object_name.name }}" ref="attachmentObjectName" v-bind:value='objectName'>
|
||||||
</div>
|
</div>
|
||||||
<template v-if="uploadError">
|
<template v-if="uploadError">
|
||||||
<span class="usa-input__message">{{ "forms.task_order.upload_error" | translate }}</span>
|
<span class="usa-input__message">{{ "forms.task_order.upload_error" | translate }}</span>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user