What is the best way to showcase a non-image file that is stored in MongoDB (using GridFS) on a webpage?

I have a project where users can upload documents (not images) that are stored in MongoDB using GridFS. My question is, is there a way to display these documents on the site for viewing instead of just downloading them? I've tried using the createReadStream method, but it only results in the document being downloaded. I'm hoping to find a solution that will allow the document or its contents to be displayed on the webpage, maybe within an iframe. Is there a method to create a URL for the document or access the file in a different way? Thank you for any assistance.

Answer №1

<ifram

 <iframe src= 'https://www.digitalwebexpert.com/uploads/PDF/Web_Development_Using_Node_Express.pdf' frameborder="0" width="400px" height="600px"></iframe>

e>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Can jqplot be used to create this particular graph?

Can the graph be created using jqplot as shown below? The closest graph type is stacked, but there are issues with coloring and point labels. This jsfiddle showcases my attempt to create a bar chart with its legend and point labels. Is it possible to achi ...

The middleware appears to be malfunctioning, despite receiving the next statement

I am working on setting up 2 middleware functions in my Node.js application, but I'm encountering an issue where the code is not progressing beyond the first middleware. I have included the next() function in both middlewares. Can someone please help ...

searching for numerous files using mongoose

Whenever I use console.log(), this is the result When I fetch all documents with that specific id, I only receive the first document const followingUsers = await User.find({ _id: { $in: foundUser.followings } }) const getFeedData = async() => { f ...

Change the structure of the JavaScript object into a new format

I humbly ask for forgiveness as I am struggling with figuring out how to accomplish this task. It seems like we need to utilize a map function or something similar, but I am having difficulty grasping it. Below is the object 'data' that I am wor ...

Compiling Directives in AngularJS for Faster Page Loading

I'm currently experiencing performance issues in my Angular application. The root cause seems to be the excessive use of a directive on a single page. Unfortunately, I don't have the time to break down this page into multiple sections. I am seek ...

AngularJS powered edit button for Laravel route parameter

I have a data list that needs to be edited using an edit button. When clicking the edit button, I need to send the ID to a Laravel controller in order to fetch the corresponding data. The initial listing was created using Angular JS. <a class="btn" hr ...

Navigate through collections of objects containing sub-collections of more objects

The backend is sending an object that contains an array of objects, which in turn contain more arrays of objects, creating a tree structure. I need a way to navigate between these objects by following the array and then back again. What would be the most ...

Simple HTML generator using Node.js

My preference is to write my HTML in a basic and straightforward manner, without any fancy tools. The only feature I would like to have is the ability to use an include statement to easily add header, navigation, and footer sections to each page. I'v ...

Troubleshooting a Vue.js issue: How to fix a watch function that stops working after modifying

I have encountered a problem with my code. It seems to be working fine initially after the beforeMount lifecycle hook, but when I try to modify the newDate variable within my methods, it doesn't seem to track the changes. data() { return { ...

Tips for reformatting table row data into multiple rows for mobile screens using ng-repeat in Angular

Just started using Angular JS and I have some data available: var aUsers=[{'name':'sachin','runs':20000},{'name':'dravid','runs':15000},{'name':'ganguly','runs':1800 ...

Issue with module exports not being defined in IE11/Edge

I am experiencing difficulties with an npm module that was updated to ES2015. My application is built in ES2015, bundled by browserify, and compiled with babelify. I am currently trying to upgrade a npm module called credit-card for validation, which has ...

What are the steps to establish a server-sent event with Vue.js?

Could anyone provide guidance on how to implement a server sent event? I have developed a small bidding application where the auctionedItems are displayed in the following component: <div v-for="item in auctionedItems"> <Item :info="item">& ...

The picture is displayed just once, despite the fact that it was supposed to be returned 50 times within the loop

I'm encountering an issue while trying to use a for loop to render an image in a React component. The loop is not functioning as expected, resulting in the image being displayed only once on the screen even though the intention is to show the same ima ...

Link a timestamp to a datetime-local input using ng-model

My challenge is to display an <input type="datetime-local> field using the ng-model attribute to represent a timestamp: <input type="datetime-local" ng-model="object.value"> This is being achieved with: $scope.object.value = 1433109600000; ...

Arrange my Firebase Angular users based on a specific value, encountering an error stating "sort is not a function

I'm working on an application using Firebase and Angular, and I have a database containing information about my users: https://i.sstatic.net/KQNSY.png My goal is to sort the users based on their "ptsTotal". In my users.service file, I have a functi ...

Ensure that autocorrect is set to suggest the nearest possible quantity form in WordPress

I'm currently in the process of creating a webshop using WooCommerce. Our quantity system is a bit unique, as we are using WooCommerce advanced quantity, which means that quantities increase by 0.72 increments (e.g. 0.72, 1.44, 2.16 etc). The +/- butt ...

Is it possible to save uploaded images in a publicly accessible directory on Heroku?

Is it permissible to upload images to a public folder instead of the database on Heroku? ...

What steps can be taken to verify that the submitted data is a legitimate numerical pair?

When I receive a string, it should be in the following format: number,number For example: 34.798,52.123 I need to verify that the number is indeed in this format before assigning it to variables and performing calculations. There is also a concern that ...

Modify the class of the dropdown and heading 2 elements if they meet specific conditions using Animate.css

Is it possible to add a class using jQuery when two specific conditions are met? 1) If the dropdown selection is either "acting" or "backstage" 2) If the membership status is set to "Non-member" If both of these requirements are fulfilled, I would like ...

invoking an API within a map function and utilizing the response

vm.owners = parents.children.map(function(e) { getparentById(e.Id) .then(function(getresponse) { var parentLink = '<a href="/#/parent/onboard/' + e.Id + '" target="_blank">' + e.Number + "-&qu ...