Click here to Skip to main content
14,660,427 members
Home » Discussions » JavaScript
   

JavaScript

 
GeneralRe: Want to download a zip file that's returned as FileStreamResult only, I could able to download in-memory using byte array but Pin
simpledeveloper24-Oct-19 13:25
Membersimpledeveloper24-Oct-19 13:25 
Questionhas been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource Pin
simpledeveloper15-Oct-19 13:05
Membersimpledeveloper15-Oct-19 13:05 
AnswerRe: has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource Pin
jkirkerx15-Oct-19 13:54
professionaljkirkerx15-Oct-19 13:54 
AnswerRe: has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource Pin
F-ES Sitecore15-Oct-19 22:14
mveF-ES Sitecore15-Oct-19 22:14 
AnswerRe: has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource Pin
simpledeveloper16-Oct-19 7:10
Membersimpledeveloper16-Oct-19 7:10 
QuestionTrying to download Zip files that's returned from Api React Pin
simpledeveloper14-Oct-19 9:00
Membersimpledeveloper14-Oct-19 9:00 
AnswerRe: Trying to download Zip files that's returned from Api React Pin
Richard Deeming14-Oct-19 9:38
mveRichard Deeming14-Oct-19 9:38 
GeneralRe: Trying to download Zip files that's returned from Api React Pin
simpledeveloper14-Oct-19 11:45
Membersimpledeveloper14-Oct-19 11:45 
Hi Richard, after researching online a little bit I could able to do the following, now the zip file is being downloaded but the problem it seems its not downloading correctly
handleDownload = (e) => {
        e.preventDefault();

        var formData = new FormData();
        formData.append('communityname', this.state.selectedCommunity);
        formData.append('files', JSON.stringify(this.state['checkedFiles']));

        let url = clientConfiguration['filesApi.local'];

        axios({
            method: 'post',
            url: url,
            data: formData
        })
        .then(res => {
            console.log(res.data);                
            var binaryData = [];
            binaryData.push(res.data);
            const src = window.URL.createObjectURL(new Blob(binaryData, { type: "application/zip" }));

            var fileName = `${this.state['selectedCommunity']}.zip`;
            saveAs(src, fileName);
        });  
    }

The error that I am getting when uzipping the file is as below:

Can not open the file as zip archive, is not archiving, Warning Headers error.
Any help please?

modified 14-Oct-19 18:16pm.

GeneralRe: Trying to download Zip files that's returned from Api React Pin
Richard Deeming15-Oct-19 1:24
mveRichard Deeming15-Oct-19 1:24 
GeneralRe: Trying to download Zip files that's returned from Api React Pin
simpledeveloper15-Oct-19 6:31
Membersimpledeveloper15-Oct-19 6:31 
GeneralRe: Trying to download Zip files that's returned from Api React Pin
simpledeveloper15-Oct-19 8:59
Membersimpledeveloper15-Oct-19 8:59 
GeneralRe: Trying to download Zip files that's returned from Api React Pin
Richard Deeming16-Oct-19 7:49
mveRichard Deeming16-Oct-19 7:49 
GeneralRe: Trying to download Zip files that's returned from Api React Pin
simpledeveloper17-Oct-19 6:53
Membersimpledeveloper17-Oct-19 6:53 
GeneralRe: Trying to download Zip files that's returned from Api React Pin
Richard Deeming17-Oct-19 7:12
mveRichard Deeming17-Oct-19 7:12 
GeneralRe: Trying to download Zip files that's returned from Api React Pin
simpledeveloper17-Oct-19 11:40
Membersimpledeveloper17-Oct-19 11:40 
GeneralRe: Trying to download Zip files that's returned from Api React Pin
Richard Deeming18-Oct-19 1:12
mveRichard Deeming18-Oct-19 1:12 
GeneralRe: Trying to download Zip files that's returned from Api React Pin
simpledeveloper20-Oct-19 14:38
Membersimpledeveloper20-Oct-19 14:38 
GeneralRe: Trying to download Zip files that's returned from Api React Pin
simpledeveloper21-Oct-19 8:08
Membersimpledeveloper21-Oct-19 8:08 
GeneralRe: Trying to download Zip files that's returned from Api React Pin
simpledeveloper21-Oct-19 10:09
Membersimpledeveloper21-Oct-19 10:09 
AnswerRe: Trying to download Zip files that's returned from Api React Pin
simpledeveloper21-Oct-19 8:10
Membersimpledeveloper21-Oct-19 8:10 
QuestionAppending an Array of strings is giving me objects instead of strings separated with commas, my code and results are as below Pin
simpledeveloper14-Oct-19 6:32
Membersimpledeveloper14-Oct-19 6:32 
AnswerRe: Appending an Array of strings is giving me objects instead of strings separated with commas, my code and results are as below Pin
Richard Deeming14-Oct-19 7:32
mveRichard Deeming14-Oct-19 7:32 
GeneralRe: Appending an Array of strings is giving me objects instead of strings separated with commas, my code and results are as below Pin
simpledeveloper14-Oct-19 8:18
Membersimpledeveloper14-Oct-19 8:18 
QuestionCalling Api post method on button click in React Pin
simpledeveloper10-Oct-19 12:11
Membersimpledeveloper10-Oct-19 12:11 
AnswerRe: Calling Api post method on button click in React Pin
jkirkerx10-Oct-19 13:40
professionaljkirkerx10-Oct-19 13:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.