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

File uploaded resources of type application/zip not working #457

Open
sebplorenz opened this issue Sep 20, 2022 · 4 comments
Open

File uploaded resources of type application/zip not working #457

sebplorenz opened this issue Sep 20, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@sebplorenz
Copy link

sebplorenz commented Sep 20, 2022

  1. Create a new ressource
  2. when creating the resource on the "Representation" page upload a zip file and set file type to application/zip
  3. Finish creating the resource
  4. Download resource from another connector
    -> Opening the downloaded zip file fails. It is not recognized as a zip file
@omarsilva1
Copy link

I have tested the functionality to upload zip files with a python script that puts the file in the DSC. It worked fine.
I believe this is a problem in the DSC-UI @SebastianOpriel, probably the encoding on file upload.

@omarsilva1 omarsilva1 added the bug Something isn't working label Sep 21, 2022
@omarsilva1
Copy link

There might be a problem with how the DSC encodes the binary files. I have compared the binaries of an original zip file and the artifact data from the DSC and they are different.

@omarsilva1
Copy link

omarsilva1 commented Oct 17, 2022

Persisting a ZIP file with the DSC UI produces a corrupt ZIP file. The file that is returned on request is bigger than the original file, which means they can't be possibly equal. I believe 1) some zip file headers are maybe persisted as well instead of only the file or 2) the file is persisted in a different encoding.
This leads to the ZIP file being corrupt when dowloading it.

I've been experimenting with different results and managed to write a method where the content length doesnt change on output, but didnt reach a solution where the zip file is not corrupt.

There is also the possibility that the frontend is encoding the files before sending it to the DSC.

A possible consideration could be to create a separate endpoint for zip file handling. Part of the problem is that the DSC handles all input files the same (all use the same REST endpoint). It might make it easier to handle ZIP files differently than normal files. Storing the whole file content in one database entry also doesnt seem to be the best practice. I'll keep looking for alternatives.

@tmberthold
Copy link

It could be due to the UI, there the method readAsBinaryString() is used [1], which doesn't seem to work with binary data [2], the same happens in my tests for example also with a PNG file.

[1] https://github.com/International-Data-Spaces-Association/DataspaceConnectorUI/blob/a723eb0109283a219f5b273d25c30a1ee7cf4793/src/pages/dataoffering/resources/addresource/representation/ResourceRepresentationPage.js#L129
[2] https://stackoverflow.com/a/17512132

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants