ActiveStorage raw file uploads fail with "An unknown file format not allowed" due filename being lost
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 52/100
調査の方向性
lib/active_storage/service/cloudinary_service.rb の upload メソッドから始め、ActiveStorage のファイル名が Cloudinary::Uploader.upload_large にどのように渡されるかを確認してください。issue に記載された設定済みの CSV アップロードを再現し、説明どおりに元のファイル名を保持して、ActiveStorage のアップロードが unknown file format エラーなしで完了することを確認してください。
索引モデルが issue の本文から書いたものです。
説明
Bug report for Cloudinary Ruby SDK
Before proceeding, please update to latest version and test if the issue persists
Describe the bug in a sentence or two.
When uploading raw files (e.g. CSV) through the ActiveStorage integration, the Cloudinary API rejects the upload with CloudinaryException: An unknown file format not allowed.
This is a regression from the 1.x series, which used rest-client and preserved the original filename in multipart requests.
Issue Type (Can be multiple)
- Build - Cannot install or import the SDK
- Performance - Performance issues
- Behaviour - Functions are not working as expected (such as generate URL)
- Documentation - Inconsistency between the docs and behaviour
- Other (Specify)
Steps to reproduce
- Configure ActiveStorage with the Cloudinary service (config/storage.yml):
cloudinary:
service: Cloudinary
type: private
- Configure a Cloudinary upload preset as the default for "API raw" with allowed_formats: ["csv"]
- Create a model with has_one_attached :csv_file
- Upload a .csv file through ActiveStorage
- Observe the error:
ActiveStorage::IntegrityError (An unknown file format not allowed)
Caused by: CloudinaryException (An unknown file format not allowed)
Error screenshots or Stack Trace (if applicable)
…
Operating System
- Linux
- Windows
- macOS
- All
Environment and Libraries (fill in the version numbers)
- Cloudinary Ruby SDK version - 2.1.2
- Ruby Version - 3.4.1
- Rails Version - 8.1.2
- Other Libraries (Carrierwave, ActiveStorage, etc) - 0.0.0
Repository
If possible, please provide a link to a reproducible repository that showcases the problem
Suggested Fix
In lib/active_storage/service/cloudinary_service.rb, the upload method should pass the filename to the uploader as original_filename:
def upload(key, io, filename: nil, checksum: nil, **options)
instrument :upload, key: key, checksum: checksum do
begin
extra_headers = checksum.nil? ? {} : {Headers::CONTENT_MD5 => checksum}
options = @options.merge(options)
options[:original_filename] = filename.to_s if filename.present? # <-- add this
resource_type = resource_type(io, key)
options[:format] = ext_for_file(key) if resource_type == "raw"
Cloudinary::Uploader.upload_large(
io,
# ... rest unchanged
)
end
end
end
- 主要言語
- Ruby
- スター
- 420
- フォーク
- 282
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
cloudinary/cloudinary_gem のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
cloudinary/cloudinary_gem#597 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
cloudinary/cloudinary_gem#582 · コメント 1 件 ·
-
404's when fetching .eml files (from Action Mailbox)再び着手できるかも @rnamba-cloudinary が 400 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
cloudinary/cloudinary_gem#581 · コメント 1 件 ·
-
BlobKey, MirrorService and Sidekiq 8 are incompatible再び着手できるかも @const-cloudinary が 541 日前に担当しましたが、オープン中のプルリクエストはありません。 オープン
cloudinary/cloudinary_gem#573 · コメント 3 件 · 担当者 1 名 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
cloudinary/cloudinary_gem#562 · コメント 9 件 ·
cloudinary/cloudinary_gem の issue をすべて見る
似ている issue
-
area: ci benchmark build developer-experience difficulty: easy dx enhancement github-actions good first issue hacktoberfest help wanted performance quality rank: 8 kyu ruby tech: ruby
難易度 1/5 1時間未満 初心者へのやさしさ 82/100
flisk-sh/flisk-labs#22 ·
-
1.severity: security
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
15-minutes 5-minutes algorithm any-language beginner-friendly c cpp csharp easy go good first issue hacktoberfest help wanted java javascript kotlin python rust swift typescript
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
Huerte/algo-solutions-python#260 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
internal
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Kong/developer.konghq.com#8080 ·
メンテナーはふだん 1 日以内に返信