0

I am trying to design a dapp which displays files uploaded to IPFS by a user. On my web page, I wish to display thumbnails of all the files uploaded by him. For this, I designed below mentioned EJS file which reads data from a MONGODB. Inside the docs.url I have saved the complete IPFS URL.

With this approach, I am able to generate thumbnails of image files (.jpeg, .png) types, but unable to generate for .pdf, .xlsx, .doc types.

If someone has applied similar feature, can they please guide in this regards?

Thanks in advance.

    <div class="row text-center" style="display:flex; flex-wrap: wrap;">
        <% docinfo.forEach(function(docs){ %>
            <div class="col-md-3 col-sm-6">
                <div class="thumbnail">
                   <img src="<%= docs.url %>">
                   <div class="caption">
                       <h4><%= docs.name %></h4>
                   </div>
                    <p>
                       <a href="/documents/<%= docs._id %>" class="btn btn-primary">More Info</a>
                    </p>
                </div>
            </div>
        <% }); %>
</div>
1

One way is to read the Content-Type response header from the IPFS gateway and then decide to load a different image for PDFs and excel/word documents or generate actual thumbnails using a library that supports those content types.

Another way is to publish an object containing a link to the actual asset and another link to metadata about the asset. You can then read the asset's metadata and determine the content-type.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.