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
Cannot include the file name or file extension when uploading a file from a MemoryStream using FileService.cs #2634
Comments
This is a good idea, we are going to look into implementing it in the future. |
Awesome! That's good to hear. |
I think I could look into this when I get more time. |
Was just about opening the same issue. Do you have any time frame? @pakrym-stripe |
I think a option for uploading the file using |
Describe the bug
When uploading a file using FileService.cs we need the ability to set the file name and content type. Currently, if you try to upload a file using the FileCreateOptions.cs class with any type of Stream other than a FileStream it will get the default file name of "blob" with a default content type.
Our use case is to allow a user to upload their dispute evidence to our application, then send the file to Stripe using a MemoryStream. The current code in this .Net library doesn't allow us to change the file name or content type in that scenario. We'd really rather not switch to FileStream since that class is meant to be used for interacting with files stored on disk, which we don't want to do.
The culprit seems to be this code:
stripe-dotnet/src/Stripe.net/Infrastructure/FormEncoding/MultipartFormDataContent.cs
Line 44 in 84932a8
Would it be possible to include FileName and ContentType as parameters to this class and plumb them through when uploading a file?
stripe-dotnet/src/Stripe.net/Services/Files/FileCreateOptions.cs
Line 6 in 84932a8
To Reproduce
var fileService = new FileService();
var options = new FileCreateOptions
{
File = new MemoryStream(),
Purpose = FilePurpose.DisputeEvidence
};
var uploadResult = await fileService.CreateAsync(options);
Expected behavior
We should be able to set the File name and Content Type.
Code snippets
OS
Windows 10
.NET version
.Net 6.0
Library version
stripe-dotnet v39.75.1
API version
2020-08-27
Additional context
No response
The text was updated successfully, but these errors were encountered: