Skip to content

Filename must end with .docx #162

@mcauser

Description

@mcauser

Describe the bug

When upgrading from v0.8.0 to v0.9.0 and found there is a new requirement that the filename must end with .docx
This doesn't play nice when the file is an Active Storage Attachment path.

Relevant commit: 3a3c850

To Reproduce

Create a model with has_one_attached :file, with storage set to local / disk.
Upload a file.
Saved in myapp/storage/xx/yy/xxyyzz....

example

record = MyModel.find(1)

puts ActiveStorage::Blob.service.path_for(record.file.key)
=> "/Users/mike/src/myapp/storage/12/34/1234abcd5678efgh9012abcd3456"

doc = Docx::Document.open(ActiveStorage::Blob.service.path_for(record.file.key))
=> Input/output error - Invalid file format (Errno::EIO)

# Duplicate the file, add .docx extension
doc = Docx::Document.open("/Users/mike/src/myapp/storage/12/34/1234abcd5678efgh9012abcd3456.docx")
# Works fine now

Sample docx file

It's not an issue with the file contents. If I rename it to .docx, it works fine.

Expected behavior

Restore previous behaviour, where Docx::Document.open() does not check the file extension, or add the filename to options {}.

Environment

  • Ruby version: 3.4.3
  • docx gem version: 0.9.0
  • OS: macOS 14.6.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions