I want to compress a file before uploading it on server in sapui5 (image(png/jpeg/jpg)/pdf/). I want to upload a large files but i want to compress that file before uploading. Please suggest me solution ?
Asked
Active
Viewed 1,157 times
0
-
I don't think there are reliable ways to compress a file on the user's machine – Jorg Aug 08 '17 at 05:58
1 Answers
0
I think you will not be able to do it with instant upload. Instead, you should obtain the file from the change
event of the file uploader (check out the change event, it has a files parameter).
You can then use that file object together with the zip.js library to create an in-memory zip and save it into e.g. a Blob. Afterwards you simply send the blob into a POST request (e.g. look at How can javascript upload a blob?). Maybe you should also provide some file-uploading specific headers (like the Slug
).

Serban Petrescu
- 5,127
- 2
- 17
- 34