Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploaded files on IE11 and Edge #7423

Closed
ja1979 opened this issue Apr 5, 2018 · 7 comments
Closed

Uploaded files on IE11 and Edge #7423

ja1979 opened this issue Apr 5, 2018 · 7 comments
Milestone

Comments

@ja1979
Copy link

ja1979 commented Apr 5, 2018

Overview of the issue

Uploaded files are not opened in Internet Explorer 11 (IE11)

Motivation for or Use Case

It works perfectly on Chrome and Firefox.

Reproduce the error

Create any Entity with a Blob field and try uploading a file. Files uploaded are not opened in IE11.

Related issues

N/A

Suggest a Fix

I guest the problem is with IFRAME tag which are not supported anymore in IE11.

JHipster Version(s)

4.14.1

JHipster configuration

jhipster info

Using JHipster version installed locally in current project's node_modules
Executing jhipster:info
Options:
Welcome to the JHipster Information Sub-Generator

JHipster Version(s)
[email protected] /mnt/myfiles/jhipster/attachment
└── [email protected] 

JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.mycompany.myapp",
      "nativeLanguage": "en"
    },
    "jhipsterVersion": "4.14.1",
    "baseName": "attachment",
    "packageName": "com.mycompany.myapp",
    "packageFolder": "com/mycompany/myapp",
    "serverPort": "8080",
    "authenticationType": "jwt",
    "cacheProvider": "ehcache",
    "enableHibernateCache": true,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": false,
    "buildTool": "maven",
    "enableSocialSignIn": false,
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "replaced-by-jhipster-info",
    "clientFramework": "angularX",
    "useSass": false,
    "clientPackageManager": "yarn",
    "applicationType": "monolith",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "enableTranslation": true,
    "nativeLanguage": "en",
    "languages": [
      "en",
      "es"
    ]
  }
}
JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
entity Attachment (attachment) {
  name String required,
  file AnyBlob required
}


paginate Attachment with pagination
service Attachment with serviceClass

Environment and Tools

openjdk version "1.8.0_161"
OpenJDK Runtime Environment (build 1.8.0_161-b14)
OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode)

git version 2.14.3

node: v8.9.4

npm: 5.6.0

yeoman: 2.0.1

yarn: 1.5.1

Docker version 1.13.1, build 7f1fa5c-unsupported

docker-compose version 1.17.1, build 6d101fb

Congratulations, JHipster execution is complete!

.yo-rc.json

{
"generator-jhipster": {
"promptValues": {
"packageName": "com.mycompany.myapp",
"nativeLanguage": "en"
},
"jhipsterVersion": "4.14.1",
"baseName": "attachment",
"packageName": "com.mycompany.myapp",
"packageFolder": "com/mycompany/myapp",
"serverPort": "8080",
"authenticationType": "jwt",
"cacheProvider": "ehcache",
"enableHibernateCache": true,
"websocket": false,
"databaseType": "sql",
"devDatabaseType": "h2Disk",
"prodDatabaseType": "mysql",
"searchEngine": false,
"messageBroker": false,
"serviceDiscoveryType": false,
"buildTool": "maven",
"enableSocialSignIn": false,
"enableSwaggerCodegen": false,
"jwtSecretKey": "xxxxx",
"clientFramework": "angularX",
"useSass": false,
"clientPackageManager": "yarn",
"applicationType": "monolith",
"testFrameworks": [],
"jhiPrefix": "jhi",
"enableTranslation": true,
"nativeLanguage": "en",
"languages": [
"en",
"es"
]
}
}

Entity configuration(s) entityName.json files generated in the .jhipster directory

{
"fluentMethods": true,
"relationships": [],
"fields": [
{
"fieldName": "name",
"fieldType": "String",
"fieldValidateRules": [
"required"
]
},
{
"fieldName": "file",
"fieldType": "byte[]",
"fieldTypeBlobContent": "any",
"fieldValidateRules": [
"required"
]
}
],
"changelogDate": "20180405201217",
"dto": "no",
"service": "serviceClass",
"entityTableName": "attachment",
"jpaMetamodelFiltering": false,
"pagination": "pagination"
}

Browsers and Operating System

Chrome, Firefox on Linux and Windows 7: OK
IE11 on Windows 7: Problem

  • [ x] Checking this box is mandatory (this is just to show you read everything)
@deepu105
Copy link
Member

deepu105 commented Apr 6, 2018

May be its time to drop IE support?

@gmarziou
Copy link
Contributor

gmarziou commented Apr 6, 2018

I guest the problem is with IFRAME tag which are not supported anymore in IE11.

What makes you think so?
From what I researched, I can't see any mention of this, just issues about iframe and data url like: https://stackoverflow.com/questions/6102636/html-code-as-iframe-source-rather-than-a-url

So the iframe tag is in ng-jhipster which does not make it very easy to debug. Have you tried working directly in pure html and try all the related tricks you can found on the web?

@ja1979
Copy link
Author

ja1979 commented Apr 6, 2018

@gmarziou
Yes, you are right. The problem is with iframe and data url which is what ng-jhipster is using to open files.

https://msdn.microsoft.com/en-us/library/cc848897%28v=vs.85%29.aspx

I figured out the problem is present in Edge too.

And yes, I found a solutions overriding JhiDataUtils.openFile method with the following:

    openFile(contentType, data) {
        if (window.navigator && window.navigator.msSaveOrOpenBlob) {
            // console.log('IE');
            const byteCharacters = atob(data);
            const byteNumbers = new Array(byteCharacters.length);
            for (let i = 0; i < byteCharacters.length; i++) {
                byteNumbers[i] = byteCharacters.charCodeAt(i);
            }
            const byteArray = new Uint8Array(byteNumbers);
            const blob = new Blob([byteArray], {
                type: contentType
            });
            window.navigator.msSaveOrOpenBlob(blob);
        } else {
            // console.log('Other Browsers');
            return this.dataUtils.openFile(contentType, data);
        }

    }

It is not the same behavior in IE11, competed with the other browsers, but its is OK.

Could this be considered to be included in ng-jhipster?

PS: Sorry for my English. :D

@ja1979 ja1979 changed the title Uploaded files on IE11 Uploaded files on IE11 and Edge Apr 6, 2018
@gmarziou
Copy link
Contributor

gmarziou commented Apr 6, 2018

@ja1979 great work! Would you like to submit a pull request to ng-jhipster project?

@ja1979
Copy link
Author

ja1979 commented Apr 6, 2018

@gmarziou Yeap! I will do that.

@gmarziou
Copy link
Contributor

gmarziou commented Apr 6, 2018

Awesome :)

@deepu105
Copy link
Member

deepu105 commented Apr 8, 2018

closed via jhipster/ng-jhipster#66

@deepu105 deepu105 closed this as completed Apr 8, 2018
@jdubois jdubois added this to the 5.0.0-beta.1 milestone May 3, 2018
kaidohallik pushed a commit to kaidohallik/generator-jhipster that referenced this issue Nov 6, 2020
kaidohallik pushed a commit to kaidohallik/generator-jhipster that referenced this issue Nov 6, 2020
kaidohallik pushed a commit to kaidohallik/generator-jhipster that referenced this issue Nov 6, 2020
kaidohallik pushed a commit to kaidohallik/generator-jhipster that referenced this issue Nov 7, 2020
kaidohallik pushed a commit to kaidohallik/generator-jhipster that referenced this issue Nov 7, 2020
kaidohallik pushed a commit to kaidohallik/generator-jhipster that referenced this issue Nov 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants