Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to get file or file path from a MultipartFile object #2348

Open
devendrarv opened this issue Dec 26, 2024 · 2 comments
Open

Unable to get file or file path from a MultipartFile object #2348

devendrarv opened this issue Dec 26, 2024 · 2 comments
Labels
s: feature This issue indicates a feature request

Comments

@devendrarv
Copy link

Request Statement

Hello Team,

Thank you for maintaining and enhancing the Dio library; it's an essential tool for many developers. I am using the latest version of Dio and encountered a limitation that affects my use case.

Context

I am implementing a feature that requires generating a checksum key by encrypting the entire payload during request interception. While encrypting, I must include file information (e.g., file path or file content) in the checksum generation for requests containing MultipartFile.

Current Issue

Currently, the MultipartFile class does not provide a direct way to access file information such as the file path or File object during request interception. This limitation makes it challenging to include the file content in the encryption process.

Feature Request

I kindly request the addition of a parameter or method in the MultipartFile class to access file information, such as:

The file path (if applicable).
A File object (if the source file exists).

Example

final file = MultipartFile.fromFileSync('path/to/file', filename: 'example.txt');
// Access file information
print(file.filePath); // Outputs: path/to/file
print(file.file);     // Outputs: File object

Benefits

Enables comprehensive payload encryption during interception, including file content.
Simplifies workflows that rely on accessing file metadata or content.

Thank you for considering this feature request. I am happy to provide additional details or talk about this more if you need them.

Solution Brainstorm

No response

@devendrarv devendrarv added the s: feature This issue indicates a feature request label Dec 26, 2024
@krishpranav
Copy link

Hi, can i implement this feature?

@YukiAttano
Copy link

Some workarounds:

I did not test it myself, but are you looking for the Options.requestEncoder?

You can pass those Options to your request, which seems to let you encode the request.

Another way would be to pass the encryption logic to MultipartFile.fromStream() and probably subclass that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s: feature This issue indicates a feature request
Projects
None yet
Development

No branches or pull requests

3 participants