I have downloaded Sample Project for file upload and download but it does not work file download for ios and android. Is the bug still going on for this relase also? If not could you share a working code for picture download sample code?
You can use following codes for file download.It works fine for me.Also, you can reach sample codes from the guides.
var webClientDownload = new SMF.Net.WebClient({
url : "http://services.smartface.io/File/Download/javascript.js",
httpMethod : "GET",
autoFileSave : true,
onSyndicationSuccess : function (e) {
alert("downloaded Javascript.js");
},
onServerError : function (e) {
alert("An error occured");
},
responseHandling : SMF.Net.ResponseHandling.forceFile
});
function Page1_cntDownload_OnPressed(e) {
webClientDownload.run();
}
Related
I am trying to open and preview a PDF from a capacitor application.
Here is my code :
const { Browser } = Plugins;
let base64Pdf = "";
var contentType = "application/pdf";
var dataBlob = this.b64toBlob(base64Pdf, contentType);
await Browser.open({ url: URL.createObjectURL(dataBlob) }).then(() => {
console.log("PDF OK");
}).catch(err => {
console.log(err);
})
This is working great on web, but does not work on iOS. I get an error saying that the URL is invalid. I also tried to use
window.open(URL.createObjectURL(dataBlob), '_blank');
and
window.open(URL.createObjectURL(dataBlob), '_system');
But none of these work. I do not get any error output.
When using self, the PDF is opening well, but since it opens inside the webview, there is no more control and the user is stuck :
window.open(URL.createObjectURL(dataBlob), '_system');
Thanks in advance for any help
When using the Cameara to take a picture with destinationType: this.camera.DestinationType.FILE_URI, the resulting URL will not work to display the image. For example, when attempting to take a photo like this:
this.camera.getPicture(options).then((url) => {
// Load Image
this.imagePath = url;
}, (err) => {
console.log(err);
});
Attempting to display it as <img [src]="imagePath" > will result in an error (file not found).
The problem here is that the URL is in the file:///storage... path instead of the correct one based on localhost.
In previous versions of Ionic, this would be solved by using normalizeURL. This will not work on Ionic 4 (or at least I could not make it work).
To solve this issue, you will need to use convertFileSrc():
import {WebView} from '#ionic-native/ionic-webview/ngx';
...
this.camera.getPicture(options).then((url) => {
// Load Image
this.imagePath = this.webview.convertFileSrc(url);
}, (err) => {
console.log(err);
});
Now the image URL will be in the appropriate http://localhost:8080/_file_/storage... format and will load correctly.
See WKWebView - Ionic Docs for more information.
In my case, the following code works with me
const downloadFileURL = 'file:///...';
// Convert a `file://` URL to a URL that is compatible with the local web server in the Web View plugin.
const displayedImg = (<any>window).Ionic.WebView.convertFileSrc(downloadFileURL);
In case some gots here looking for the answer on ionic4, check this out
"Not allowed to load local resource" for Local image from Remote page in PhoneGap Build
and look for the answer from #Alok Singh that's how I got it working on ionic4 and even works with livereload
UPDATE december 2021:
You have to install the new Ionic Webview
RUN:
ionic cordova plugin add cordova-plugin-ionic-webview
npm install #awesome-cordova-plugins/ionic-webview
Import it in app.module and your page where you wanna use it:
import { WebView } from '#awesome-cordova-plugins/ionic-webview/ngx';
image = "";
constructor(private webview: WebView){}
Then this will work:
this.camera.getPicture(options).then((imageData) => {
this.image = this.webview.convertFileSrc(imageData)
}, (err) => {
// Handle error
});
And show it in the HTML page:
<img [src]="image" alt="">
I'm working on an ionic mobile application where I needed to read videos on streaming by providing the URI of the video online. So I used cordova-plugin-media-streamingplugin offered by cordova.
My problem is that: the window reading the video closes automatically after the video finishes, the user won't be able to play the video again in this window.
In the official documentation of the plugin [that i found here], there is an attribute called shouldAutoClosethat should be set to false to avoid that problem. But this didn't work for me.
Here is the code I used to play a video on streaming :
startVideo(item : Multimediasendtrust) {
let options = {
successCallback: () => { console.log('Finished Video') },
errorCallback: (e) => { console.log('Error: ', e) },
orientation: 'portrait',
controls: true,
shouldAutoClose: false
};
console.log('those are option ',options );
console.log('the link of the video ', item.url_media);
this.streamingMedia.playVideo(item.url_media, options); }
Can anyone help please. Thanks in advance.
I´m new to Ionic2, but experienced in web development. Just learning new platform at the moment.
So I have tried to integrate the Anyline OCR SDK
https://github.com/Anyline/anyline-ocr-cordova-module
but I am failing, it seems to me that the plugin is written in Javascript and not compatible with TS but I´m not sure...
Is there anyone out there that could help?
Thanks,
Ben
Not sure if you still need help with that, but for those out there who are looking for a working solution, here is mine:
1 - Add the Anyline Plugin to your project cordova plugin add io-anyline-cordova
2 - Create a new file ionic g provider anyline
3 - add this code to your anyline.ts file:
export class OCR {
constructor() {
if (anylineScan === undefined) {
var anylineScan = {};
}
}
anylineScan = {
onResult: function (result) {
console.log("MRZ result: " + JSON.stringify(result));
//do what you want here with the result
},
onError: function (error) {
console.log("scanning error");
},
scan: function () {
var licenseKey = "enterYourLicenceKeyHere";
try {
(<any>window).cordova.exec(this.onResult, this.onError, "AnylineSDK", "OCR", [licenseKey, {
"captureResolution":"1080p",
//your other config setting here
}]);
}
catch (e){
console.log("Cannot open scan view: ERROR occurred");
}
}
}
4 - Add the file references to your app.module.ts file
import { OCR } from '../yourFolderName/anyline';
...
providers: [Storage, OCR]
5 - In your page.ts file add the following call:
this.anyline.anylineScan.scan();
Important! It will not work in the browser, make sure you run ionic platform add ios (or android) and run the app on a device.
This should work!
Good luck and happy coding :-)
Trying to upload image to my server can dev's help me plz with this. I am using this code to upload image
`var webClientUpload = new SMF.Net.WebClient({
url : "http://services.smartface.io/Samples/File/Upload",
httpMethod : "PUT", ploading
onSyndicationSuccess : function (e) {
Pages.startPage.cntUpload.lblSubtitleUpload.text = "Your file has"
Pages.startPage.cntUpload.aiUpload.visible = false;
Pages.startPage.cntUpload.imgUpload.visible = true;
},
onServerError : function (e) {
Pages.startPage.cntUpload.lblSubtitleUpload.text = "There has been";
Pages.startPage.cntUpload.aiUpload.visible = false;
Pages.startPage.cntUpload.imgUpload.visible = true;
}
});'
and I am changing the service to my service
http://devserver:922/UVService.svc
Help me please anyone.
As i know Smartface don't support file operations like upload, download or move.
Hope next releases solves the problem.