how to compress file in sapui5 before uploading on server in instant upload? - sapui5

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 ?

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).

Related

Dropbox Python API - Upload function

Let's say that I upload a text file to Dropbox via Python API.
If I constantly append 1Mb of data per day and sync it, in the Day 10 will Dropbox upload all the 10Mb and replace the old file or just 1Mb and extend to the 9Mb file that have left?
If you're uploading a file to Dropbox using the Dropbox Python SDK, e.g., with the files_upload method, the entire file contents has to be uploaded with every upload. The Dropbox API doesn't offer a way to just append to existing files, but I'll pass this along as a feature request.

Using tHttpRequest to download an Excel File from Sharepoint with Authentication

I want to download an Excel file from Sharepoint and use it as input for a tFileInputExcel component. tHttpRequest seems to be the only component able to download files from a sharepoint server with authentication.
What of course works is to download the file via tHttpRequest, write the response to a file, and load that file with the tFileInputExcel component.
Example, but I don't want it like that.
However, I do not want an intermediate file and use the "stream" functionality of the tFileInputExcel component. What I do not achieve is to convert the downloaded content into a stream that is usable by the excel component:
((java.io.InputStream)globalMap.get("what goes here? And where does it come from?"))
Here's an example using the tFileFetch component, but this component is not able to download from sharepoint with authentication.
You can do it by writing the content returned by tHttpRequest to a ByteArrayOutputStream inside a tJavaFlex, then converting it to a ByteArrayInputStream like this :
Make sure you uncheck "Write response content to file" on tHttpRequest.
In my example I download a text file because I don't have a link to an excel, but it works the same. You can read your file as an input stream like this :
I extended the tHttpRequest component and created tHttpRequestEx. The new component saves a ByteArrayInputStream to the global map which can be read from the tFileInputExcel component:
((java.io.ByteArrayInputStream)globalMap.get("tHttpRequestEx_1_INPUT_STREAM"))
I uploaded the component on exchange.talend.com.
Of course this has the big disadvantage to use a non-standard component. It may be the better solution to stick with the file download, and use tCreateTemporaryFile to deal with the complexity of creating and deleting a file.

File Uploading in Sakai

I want to know if there is a 'right' way to make file uploads through custom tools.
I've seen the https://confluence.sakaiproject.org/display/BOOT/File+Uploads+with+RSF guide and it seens ok, but It stops with the file in memory with no further info. I can built a random file upload code but I want to make it Sakai-friendly (Using ContentHosting and Resources service?)
Any hints?
Thanks
The link you provided for the first part is a good example of how to get the upload initially processed. Going through RequestFilter will get your files validated, but you can use whatever method you want to upload it.
For the second part, I'd look at the ContentHosting webservice (createContentItem) for an example of how to add a file from a byte[] in memory after you've uploaded it.
These methods in ContentHostingService also accept InputStream as a parameter as of 2.7 (KNL-325), so you don't have to store the entire file in memory and can stream it as you're uploading, which you should do if the files are of any reasonable size.

Is it possible to download a file that uploaded via filepicker in chucks?

Is it possible to download a file that I uploaded via filepicker, in chucks? I work on a platform that doesn't allow me to download files overs a certain size programmatically, (httprequest) so I have a need to retrieve the file in chucks and reassemble them.
No we don't currently provide this functionality.

Browse file and store file url for uploading it later

I have a form in which you enter some data and you are able to attach files. All I wanna do is have a Browse button so i can select the file and store that file url in some var, so later when i want to submit the form...y can read that var and upload the file using its url. Im using Scala Lift. I search for examples in the web but couldnt find anything helpful. I only want to select the file and store the file url. Can someone help me? Thanks!
You can't store path to file on client's drive. Even if you get path like this, you can't upload file that is not manually selected by client.
I suggest doing AJAX based client.