Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to properly display Cloudinary attachment in new tab?

My React app displays list of documents and images the right way using Cloudinary link. This is how I do it:

{attachmentList.map((val, key) => {
  return (
    <tbody key = {key}>
      <tr style={{backgroundColor:'#e7ecf0'}}>
        <td>
          <Link
            to={val.project_attachment_url}
            target="_blank"
            rel="noopener noreferrer"
          >
            {val.project_attachment_url}
          </Link>
        </td>
      </tr>
    </tbody>
  )
})}

However, when I click on the link, it opened in a new tab and the document won’t show. Somehow, the link displayed inside the table is correct but the link returned from the tab becomes something like this: http://localhost:3000/viewproject/https://res.cloudinary.com/xxx/image/upload/v1655999804/tw9upsc87rrsxgregsmy.pdf where it includes the localhost link as well. I don’t know how I can make it to be only starting from https://res.cloudinary.com/xxx...?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

use <a href={yourCloudinaryUrl}> instead of <Link>

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading