Question T12738
Visible to All Users

FIleDownload customization in SurveyCreator

created 2 years ago

Hi,

Is there any option to customize http request (add auth header) when downloading a file in SurveyCreator.
I've customize upload according to https://surveyjs.io/survey-creator/examples/file-upload/reactjs#content-code and url appears in my survey json definition, but images are not displayed as not able to add auth header for a download.

Thanks,
Piotr

Show previous comments (2)

    Hello Piotr,
    Thank you for the update. From what I gather, you wish to include HTTP request headers when an Image question makes a server request to load an image by the specified URL. Please confirm this.

      I am talking about the stage when we are creating a survey in a SurveyCreator, so it doesn't have to be a question but also image logo at the top of the page, but I mean a design canvas.

        Hello Piotr,
        I understand that you wish to pass request headers to allow a survey to download images such as survey logo and image questions. Please let me check how to complete this. I'll update this ticket shortly.

        Answers approved by surveyjs Support

        created 2 years ago

        Hello Piotr,
        Please accept my apologies for the delayed reply.

        In SurveyJS, we use an Image embed HTML element to display survey images. If you provide an image URL to download an image, the URL you assign to the image URL/link property of a survey element should not require JWT Authorization. Rather, the image should be delivered by an API as a static asset.

        If you do need to include an authentication header when downloading an image for a survey, you can use JavaScript to make an AJAX request to retrieve the image and set the authentication header in the request headers. You can then convert the images to base-64 encoded strings and replace the image URLs in your survey.

        Alternatively, you can load the images as base-64 encoded strings directly into your survey JSON definition without handling the onUploadFile function.

        Please let me know if you have any further questions.