Don't return filename from upload
The uploader only needs to return the object_name of the uploaded object. The filename is read directly from the input, so there's no need to return it as well.
This commit is contained in:
parent
e8dde759ad
commit
442e136a4b
@ -25,12 +25,12 @@ class Attachment(Base, mixins.TimestampsMixin):
|
||||
@classmethod
|
||||
def attach(cls, fyle, resource=None, resource_id=None):
|
||||
try:
|
||||
filename, object_name = app.uploader.upload(fyle)
|
||||
object_name = app.uploader.upload(fyle)
|
||||
except UploadError as e:
|
||||
raise AttachmentError("Could not add attachment. " + str(e))
|
||||
|
||||
attachment = Attachment(
|
||||
filename=filename,
|
||||
filename=fyle.filename,
|
||||
object_name=object_name,
|
||||
resource=resource,
|
||||
resource_id=resource_id,
|
||||
|
@ -35,7 +35,7 @@ class Uploader:
|
||||
object_name=object_name,
|
||||
extra={"acl": "private"},
|
||||
)
|
||||
return (fyle.filename, object_name)
|
||||
return object_name
|
||||
|
||||
def download_stream(self, object_name):
|
||||
obj = self.container.get_object(object_name=object_name)
|
||||
|
@ -9,6 +9,7 @@ from tests.mocks import PDF_FILENAME
|
||||
def test_attach(pdf_upload):
|
||||
attachment = Attachment.attach(pdf_upload)
|
||||
assert attachment.filename == PDF_FILENAME
|
||||
assert attachment.object_name is not None
|
||||
|
||||
|
||||
def test_attach_raises():
|
||||
|
@ -21,8 +21,7 @@ NONPDF_FILENAME = "tests/fixtures/disa-pki.html"
|
||||
|
||||
|
||||
def test_upload(uploader, upload_dir, pdf_upload):
|
||||
filename, object_name = uploader.upload(pdf_upload)
|
||||
assert filename == PDF_FILENAME
|
||||
object_name = uploader.upload(pdf_upload)
|
||||
assert os.path.isfile(os.path.join(upload_dir, object_name))
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user