I'm using filepicker in my application.
After uploading it is returning a Blob object with details like size, name.
How can i get Uploading source type from this?
Related
I'm using flutter dropzone package, how can I get the mp4 file from blob url or uint8list?
how can I get the mp4 file from blob url or uint8list?
You can not get a reference of a File object pointing to the dropped File. That is simply not possible in a web environment.
But as you have already pointed out correctly, you can get the file contents as a Uint8List or Stream<List<int>>. Should not really make a difference since the content of the File is usually all one cares about.
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).
I have a gallery module, the functionality implemented in this module as below
- getting the file path from the server using ajaxrequest
- the response will be json object of all image file path
- setting the filepath in image src attribute
As we are using ajax request, the images are loading in online mode only.
so how to implement the functionality so that images should show in offline also.
You may consider returning images as base64 string from the server and store them in a localstorage.
On the view use data-ng-src directive like this .
In your controller check if there is no connection and set base64 string from the localstorage as this: $scope.data.image_url=
After loading an image once, your best bet is going to be get a base64 representation of it, and then persisting that to disk.
Get the base64 representation of the image here:
Get image data in JavaScript?
Write the base64 data to disk using ng-cordova/ionic native and the writeFile method using the Cordova file plugin.
http://ngcordova.com/docs/plugins/file/
writeFile(path, file, data, replace)
There are some great answers here that I would like to build on...
I would suggest using PouchDB as a cache for base64 and/or Blob data after you have downloaded the original (one of my apps does the same thing with mp3 data converted to a Blob). You could then implement a method that checks the cache for the image before making a network request.
Nolan Lawson has created an excellent library for these binary conversions: https://github.com/nolanlawson/blob-util
Just save the base64 string to your PouchDB instance after the initial download, you can then check for that data before your app reaches out to the network.
Just beware of storage limits on iOS Safari (~50mb default)...
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.
Okay so I want to load a image from a URL in my app, however this image will need to be updated every month manually, therefore its not practical to have to submit a new update to apple every time the url changes. So does anyone no of a picture/file sharing site that would allow me keep the same URL for the image even when uploading a updated version of the image?
You can just use the same url for the image that you want presented hosted on your domain or a hosting site.
So something like
http://www.mydomain.com/appImage.jpg
That you always call to and always is the address of the relevant image. Basically the URL is just a location that you can store any image at.
Up to my knowledge, in order to achieve this you will need a static URL. So that means you'll have to buy a domain from a hosting service.
Or if not you can use Google Drive for this. But you'll have to do some more coding for this.
Try using Google Drive:
Upload a text file(*.txt) to your Google Drive and get a shareable link. Convert it to a direct download link.
Next save whatever your image as a String (base64); I have attached some interesting coding examples below.
Then give the file link to your app; download the file; read the String(base64) convert it back to image format.
When you want to update the Image convert it to a String; open the Google Drive; edit your file using Drive Notepad (Do not use
Google Docs) and simply save it Ctrl+S.
Useful Links:
Google Drive Direct Link Generator
Convert between UIImage and Base64 string
Converting between Image and Base64 string in iOS
Java BufferedImage to PNG format Base64 String
Convert image to base64 with java
Hope this helps.