[PR #5306] [MERGED] fix(relay): expand MIME type support #5155

Closed
opened 2026-03-17 02:37:40 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/5306
Author: @CuriousCorrelation
Created: 8/5/2025
Status: Merged
Merged: 8/8/2025
Merged by: @jamesgeorge007

Base: patchHead: desktop-feat-expand-relay-mime-type-support


📝 Commits (1)

  • 421061f fix(relay): expand MIME type support

📊 Changes

8 files changed (+95 additions, -16 deletions)

View changed files

📝 packages/hoppscotch-agent/src-tauri/Cargo.lock (+1 -1)
📝 packages/hoppscotch-common/src/components.d.ts (+1 -2)
📝 packages/hoppscotch-desktop/plugin-workspace/relay/src/interop.rs (+83 -3)
📝 packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-relay/Cargo.lock (+1 -1)
📝 packages/hoppscotch-desktop/src-tauri/Cargo.lock (+2 -2)
📝 packages/hoppscotch-desktop/src-tauri/Cargo.toml (+1 -1)
📝 packages/hoppscotch-kernel/package.json (+1 -1)
📝 pnpm-lock.yaml (+5 -5)

📄 Description

This fixes file uploads incorrectly showing MIME type as "Other" instead
of their actual content types by expanding the MediaType enum relay
to include common audio, video, and image formats.

Basically MediaType enum is used for both ContentType which would
map to ContentType from hoppscotch-data (e.g. multipart/form-data)
but also to FormValue in interop

pub enum FormValue {
    ...
    File {
        filename: String,
        content_type: MediaType,
        data: Bytes,
    },
}

although the later should be much more pervasive.

This is a follow up on #5244

Closes FE-887
Closes #3810
Closes #5223
Closes #5233

The issue occurred because the relay's MediaType couldn't deserialize
beyond the basic types (text, JSON, XML, etc.), lacked support for
other media file types. The TypeScript layer correctly detected MIME
types (e.g., "audio/x-m4a"), but the deserialization process fell back
to MediaType::Other. Main reason for servers performing strict MIME
validation to reject uploads.

Before After
image image
image image
image image

What's changed

The MediaType enum in /src/interop.rs now includes:

Audio types: AudioMpeg, AudioMp4, AudioXM4a, AudioWav, AudioOgg,
AudioAac, AudioFlac

Video types: VideoMp4, VideoAvi, VideoQuicktime, VideoXMsvideo,
VideoWebm, VideoXFlv

Image types: ImagePng, ImageJpeg, ImageGif, ImageSvgXml, ImageWebp,
ImageBmp, ImageXIcon

Some more application types: ApplicationPdf, ApplicationZip,
ApplicationJavascript

Each variant includes proper serde rename attributes to match standard
MIME type strings
(like #[serde(rename = "audio/x-m4a")] for AudioXM4a).

Testing

Use httpbin.org/post with this request setup:

  • Method: POST
  • URL: https://httpbin.org/post
  • Body: multipart/form-data with file upload
  • Test files: .m4a, .png, .mp4, or other media files

See:
https://github.com/hoppscotch/hoppscotch/pull/5228#issuecomment-3052343920

Previously:

"files": {
  "audio-file": "data:Other;base64,..." 
  } 

Expected:

"files": {
  "audio-file": "data:audio/x-m4a;base64,..."
  } 

Using curl:

curl --request POST \
  --url https://httpbin.org/post \ 
  --header 'content-type: multipart/form-data' \ 
  --form audio-file=@sample.m4a 

This change maintains backward compatibility since MediaType::Other
remains as the go-to fallback for any unrecognized types.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/hoppscotch/hoppscotch/pull/5306 **Author:** [@CuriousCorrelation](https://github.com/CuriousCorrelation) **Created:** 8/5/2025 **Status:** ✅ Merged **Merged:** 8/8/2025 **Merged by:** [@jamesgeorge007](https://github.com/jamesgeorge007) **Base:** `patch` ← **Head:** `desktop-feat-expand-relay-mime-type-support` --- ### 📝 Commits (1) - [`421061f`](https://github.com/hoppscotch/hoppscotch/commit/421061fed27df5b60d47cf3ff84661979bfd835e) fix(relay): expand MIME type support ### 📊 Changes **8 files changed** (+95 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-agent/src-tauri/Cargo.lock` (+1 -1) 📝 `packages/hoppscotch-common/src/components.d.ts` (+1 -2) 📝 `packages/hoppscotch-desktop/plugin-workspace/relay/src/interop.rs` (+83 -3) 📝 `packages/hoppscotch-desktop/plugin-workspace/tauri-plugin-relay/Cargo.lock` (+1 -1) 📝 `packages/hoppscotch-desktop/src-tauri/Cargo.lock` (+2 -2) 📝 `packages/hoppscotch-desktop/src-tauri/Cargo.toml` (+1 -1) 📝 `packages/hoppscotch-kernel/package.json` (+1 -1) 📝 `pnpm-lock.yaml` (+5 -5) </details> ### 📄 Description This fixes file uploads incorrectly showing MIME type as "Other" instead of their actual content types by expanding the `MediaType` enum relay to include common audio, video, and image formats. Basically `MediaType` enum is used for both `ContentType` which would map to `ContentType` from `hoppscotch-data` (e.g. `multipart/form-data`) but also to `FormValue` in `interop` ```rust pub enum FormValue { ... File { filename: String, content_type: MediaType, data: Bytes, }, } ``` although the later should be much more pervasive. This is a follow up on #5244 Closes FE-887 Closes #3810 Closes #5223 Closes #5233 The issue occurred because the `relay`'s `MediaType` couldn't deserialize beyond the basic types (text, JSON, XML, etc.), lacked support for other media file types. The TypeScript layer correctly detected MIME types (e.g., "audio/x-m4a"), but the deserialization process fell back to `MediaType::Other`. Main reason for servers performing strict MIME validation to reject uploads. | Before | After | | --- | --- | | <img width="1372" height="800" alt="image" src="https://github.com/user-attachments/assets/72bdca0d-5894-4a69-a1b5-516896193419" /> | <img width="1372" height="800" alt="image" src="https://github.com/user-attachments/assets/35ebf443-c1a7-4ce3-ae71-4291f8a1bba8" /> | | <img width="1372" height="800" alt="image" src="https://github.com/user-attachments/assets/65840d90-a70b-4ffb-8ba8-ca5a7b7aceff" /> | <img width="1372" height="800" alt="image" src="https://github.com/user-attachments/assets/5be09223-c49c-4fd6-854b-8cdef8926053" /> | | <img width="1372" height="800" alt="image" src="https://github.com/user-attachments/assets/e1b936d2-8b6b-41fd-8bdb-148f7efab904" /> | <img width="1372" height="800" alt="image" src="https://github.com/user-attachments/assets/baf1c2b9-aef0-4b13-9378-4bd71a29e5ec" /> | ### What's changed The `MediaType` enum in `/src/interop.rs` now includes: Audio types: AudioMpeg, AudioMp4, AudioXM4a, AudioWav, AudioOgg, AudioAac, AudioFlac Video types: VideoMp4, VideoAvi, VideoQuicktime, VideoXMsvideo, VideoWebm, VideoXFlv Image types: ImagePng, ImageJpeg, ImageGif, ImageSvgXml, ImageWebp, ImageBmp, ImageXIcon Some more application types: ApplicationPdf, ApplicationZip, ApplicationJavascript Each variant includes proper `serde` `rename` attributes to match standard MIME type strings (like `#[serde(rename = "audio/x-m4a")]` for AudioXM4a). ### Testing Use `httpbin.org/post` with this request setup: - Method: POST - URL: https://httpbin.org/post - Body: multipart/form-data with file upload - Test files: .m4a, .png, .mp4, or other media files See: https://github.com/hoppscotch/hoppscotch/pull/5228#issuecomment-3052343920 Previously: ```json "files": { "audio-file": "data:Other;base64,..." } ``` Expected: ```json "files": { "audio-file": "data:audio/x-m4a;base64,..." } ``` Using curl: ```bash curl --request POST \ --url https://httpbin.org/post \ --header 'content-type: multipart/form-data' \ --form audio-file=@sample.m4a ``` This change maintains backward compatibility since `MediaType::Other ` remains as the go-to fallback for any unrecognized types. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:37:40 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hoppscotch#5155
No description provided.