question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to convert File to FileParameter in Typescript?

See original GitHub issue

Hi,

I tried to find the information in the issues, wiki and stackoverflow but I didn’t find it.

In my Api, there is a DTO with a IFormFile, which generate using nswastudio a function asking for a FileParameter.

export interface FileParameter {
    data: any;
    fileName: string;
}

When a file is selected with input type=file, I don’t know how to convert the File to a FileParameter.

How could I do that?

Thanks

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
spectacularbobcommented, Aug 19, 2020

This worked for me

public uploadFile(file: File) {
    let fileParameter: FileParameter = { data: file, fileName: file.name };
    //Pass it to your service
}
0reactions
ranoufcommented, Jun 2, 2023

Thanks for your help:)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to extract data and file name from args for upload files?
2: Change public files: Array<FileParameter> = new Array<FileParam>(); to public files: Array<any> = new Array<any>();.
Read more >
File: File() constructor - Web APIs - MDN Web Docs
The File() constructor creates a new File object instance.
Read more >
script - Makes a typescript of a terminal session
Begin recording the shell session activity by issuing the script command: script · Start removing the files and then end the recording of...
Read more >
Upload Small Files to a Web API Using Angular
Convert the file data into a byte array using the FromBase64String() method on the .NET Convert class. Store the results of calling this...
Read more >
File upload | NestJS - A progressive Node.js framework
To upload a single file, simply tie the FileInterceptor() interceptor to the route handler and extract file from the request using the @UploadedFile()...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found