You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
I think a option for uploading the file using ReadOnlySpan<byte> should be possible as well for performance critical applications as well (think things like hospital applications for example where every bit of performance it critical to do anything and everything and can sometimes mean life or death).
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: