How would you fix it? Show 6 more comments. I hate to post the simple thank you comments as they are usually not value added I had been searching struggling with this for WAY too many hours today. I had been searching for the code you have from this. Thanks, works without needing any plugins etc. Saved my day, big thumbs up for you. You should pass this. Show 4 more comments.
Andreo Andreo 11 3 3 bronze badges. J Scott J Scott 1 1 silver badge 6 6 bronze badges. Siddharth Siddharth 31 1 1 bronze badge. Aswathy 7 7 bronze badges. David Kroese David Kroese 13 5 5 bronze badges. Sign up or log in Sign up using Google. To accomplish that, we have to add logic to the download.
With this, we can wrap up the implementation of the download operation. To choose a file to download, we first need to list those files somewhere in the application and trigger the download request with the help of the UI components. As mentioned in the beginning, we will load a list of users from the database and take their corresponding profile pictures.
But to have something to show, we first need to create some users. On the homepage of the application, by entering credentials and uploading a picture, we can successfully create a User. When we add a user, the profile picture will also automatically appear in a folder inside our application. For the sake of simplicity, we will show them below the user creation form.
Each photo in the list will have an associated download button which will trigger the download for that particular file. For the realization of the idea of iterating through a list of users, we first need to load the users from the database. Luckily, we already have a method in the app.
Here, we also added the selector for the DownloadComponent so its template renders next to each profile picture. By clicking the download button, we will get a message that we have hit the download end-point:. With this implementation, we are manipulating the user data that we read from the database, selecting image properties, and showing them. But what if we want to read the files directly from a folder? To be able to read from a folder, we need its path.
When we access the desired folder, we pick up the files with specific extensions since we only want pictures. That way we will get paths for each file and render them on the UI as we do now by reading from the database. Firstly, we are going to add a new end-point to our FileController. We will fill it with the necessary logic for reading. Note: If the only photos in the folder are the ones associated with users, try to add more files so that there is a clear difference between these two approaches.
The updated FileController. I am using swagger for APIs in my project. Blob in angular 8. Your email address will not be published. Notify me of follow-up comments by email. Notify me of new posts by email. See also ASP. NET Core Middleware. How to add Treeview in Angular 6 and Asp. Net Core Application. Enjoyed it? Share the love! Share this content Opens in a new window Opens in a new window Opens in a new window Opens in a new window Opens in a new window. He is currently working as a senior software developer in Edinburgh, UK.
He is the primary author and the founder of onthecode. Noe 19 Dec Reply. Excelente Post. Me salvo la vida. Leave a Reply Cancel reply Comment.
0コメント