Trying to open a file from ionic react code, but couldn't do it as it throws an error with fileOpener.open is not recognized or undefined.
import { FileOpener } from '#awesome-cordova-plugins/file-opener/ngx';
const callFileOpen = () => {
fileOpener.open("file:///C:/Users/seedapps.shankar/Downloads/sample.xlsx",'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')
.then(() => console.log('File is opened'))
.catch(e => console.log('Error opening file', e));
}
Related
I am using laravel 9 sanctum token, the authentication part is all right.
But when I'm inside and I do a request to a protected route, it throws 401 Unauthorized because when it went through the boot it didn't take the token but if I load the page again the data appears.
Part of the code below:
const api = axios.create({ baseURL: "http://localhost:8000/api/" });
api.defaults.headers["Authorization"] = `Bearer ${localStorage.getItem("token")}`;
// ...
setup() {
const posts = ref([])
onMounted(() => {
getPosts()
})
const getPosts = async () => {
try {
const response = await api.get("/blogs")
posts.value = response.data.data
} catch (error) {
alert(error)
}
}
The google picker dialog keeps asking to authenticate even after authenticating.
This is what it shows:
https://i.stack.imgur.com/PC4xD.png
When the sign-in button is clicked the authentication popup disappears immediately after showing for like a millisecond.
The First thing I tried was following the Google Picker API documentation at https://developers.google.com/drive/picker/guides/overview
Though I ran into a problem with that example.
tokenClient = google.accounts.oauth2.initTokenClient({
client_id: 'YOUR_CLIENT_ID',
scope: 'YOUR_SCOPES',
callback: '', // defined later
});
gisInited = true;
the snippet above won't work because the property "accounts" no longer exists on the object "google". For some reason, the documentation is not up to date.
My second idea was to use the "gapi" library to handle the authentication process but then I ran in into the current issue.
Is there something I am missing?
(Current Code)
` gapi.load('client:auth2', () => {
initClient();
});
const initClient = () => {
try {
gapi.client.init({
apiKey: google_devkey,
clientId: google_client_id,
discoveryDocs: ['https://www.googleapis.com/discovery/v1/apis/drive/v3/rest'],
scope: 'https://www.googleapis.com/auth/drive.metadata.readonly',
}).then(() => {
gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);
updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get());
})
} catch (e) {
console.error("Auth Init ERROR:", e)
}
};
const updateSigninStatus = (isSignedIn) => {
console.error("isSignedIn::", isSignedIn)
if (isSignedIn) {
console.error("init Create Picker")
createPicker();
} else {
// prompt user to sign in
handleAuth();
}
};
const handleAuth = (event) => {
gapi.auth2.authorize({
client_id: settings.google_client_id,
scope: 'https://www.googleapis.com/auth/drive.metadata.readonly',
}, () => { })
};
function createPicker() {
let accessToken = gapi.auth2.getAuthInstance().currentUser.get().getAuthResponse().id_token || null
console.error("TOKEN:", accessToken)
if (accessToken) {
const picker = new window.google.picker.PickerBuilder()
.addView(window.google.picker.ViewId.DOCS_IMAGES_AND_VIDEOS)
.setOAuthToken(accessToken)
.setDeveloperKey(google_devkey)
.setCallback(pickerCallback)
.build();
picker.setVisible(true);
}
}
`
In my project, a Java client program tries to connect an Oracle DB server over SSL with Netty.
the client simply sends the connection string to DB server and waits the response (TCPS packets).
my code snippets are given below:
....
SSLContext sslContext = SSLContextFactory.getSslClient();
SSLEngine engine = sslContext.createSSLEngine();
engine.setEnabledProtocols(new String[]{"TLSv1"});
engine.setUseClientMode(true);
socketChannel.pipeline().addFirst("ssl",new SslHandler(engine));
....
In my handler class that extends ChannelInboundHandlerAdapter, I see that ssl handshake and peer authentication is completed successfully.
In addition to this,
ctx.channel().read();
line has been reached in the following method:
#Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
ctx.read();
if (message != null) {
ctx.writeAndFlush(Unpooled.copiedBuffer((byte[]) message)).addListener((ChannelFutureListener) (channelFuture) -> {
if (channelFuture.isSuccess()) {
ctx.channel().read();
} else {
channelFuture.cause().printStackTrace();
channelFuture.channel().close();
}
});
message = null;
}
}
however, channelRead method is never called and DB server doesn't send any data.
I will be happy if You have any suggestions.
thanks in advance.
I use InnerActive as my default Ad provide for my Windows Phone apps. I being using it since June 2013 and on my end of year analysis I realized InnerActive ads are my main source of my app crashes. The worst part is, it's code don't I don't have any control over. I already placed a "try catch" around every operation that requests Inneractive Ads.
Does anyone have any idea how can I resolve this issue?
Where is the code I use to request the Ads:
private void LoadInnerActiveAds()
{
try
{
if (DeviceNetworkInformation.IsNetworkAvailable)
{
// Watch location
if (_allowAdLocationTracker)
{
IaLocationClass iaLocation = new IaLocationClass();
iaLocation.Done += new EventHandler<IaLocationEventArgs>(InnerActiveLocation_Done);
iaLocation.StartWatchLocation();
}
optionalParams = new Dictionary<InneractiveAd.IaOptionalParams, string>();
//optionalParams.Add(InneractiveAd.IaOptionalParams.Key_Gender, "m");
optionalParams.Add(InneractiveAd.IaOptionalParams.Key_Ad_Alignment, InneractiveAd.IaAdAlignment.CENTER.ToString());
optionalParams.Add(InneractiveAd.IaOptionalParams.Key_OptionalAdWidth, "480");
optionalParams.Add(InneractiveAd.IaOptionalParams.Key_OptionalAdHeight, "80");
}
//Show Add Banner. Remarks: pay attention to use Application Id from NAX
//naxAd.Childred.Count()==0 => just to add one banner control on a page. Without this, code would add as many banners as you navigate to page where banner is placed
if (optionalParams != null && AdsUIContainer.Children.Count == 0)
{
InneractiveAd iaBanner = new InneractiveAd(AdsAppId, InneractiveAd.IaAdType.IaAdType_Banner, 30, optionalParams);
iaBanner.AdFailed += new InneractiveAd.IaAdFailed(InneractiveAd_AdFailed);
Deployment.Current.Dispatcher.BeginInvoke(() => { UpdateUI(iaBanner); });
}
}
catch (Exception ex)
{
InneractiveAd_AdFailed(ex);
}
}
This stacktrace might help, but keep in mind this is code I don't control.
Frame Image Function Offset
0 system_xml_ni System.Xml.XmlTextReaderImpl.Throw 0x00000036
1 system_xml_ni System.Xml.XmlTextReaderImpl.ParseDocumentContent 0x00000438
2 system_xml_ni System.Xml.XmlTextReaderImpl.Read 0x00000036
3 system_xml_ni System.Xml.XmlReader.ReadToFollowing 0x0000003c
4 inneractive_ad_ni Inneractive.Ad.InneractiveAdControl.ParseCPDXml 0x0000007c
5 inneractive_ad_ni Inneractive.Ad.InneractiveAdControl.webClient_UploadStringCompleted 0x000000aa
6 system_net_ni System.Net.WebClient.OnUploadStringCompleted 0x00000010
7 system_net_ni System.Net.WebClient.UploadStringOperationCompleted 0x00000034
Solution:
Following Soonts suggestion, this is what I came up with:
In App.xaml.cs file locate "Application_UnhandledException" method and replace it with:
// Code to execute on Unhandled Exceptions
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
if (e.ExceptionObject.StackTrace.Contains("Inneractive.Ad.InneractiveAdControl"))
{
// Recover from the error
e.Handled = true;
return;
}
if (Debugger.IsAttached)
{
// An unhandled exception has occurred; break into the debugger
Debugger.Break();
}
}
Please let me know if you find better alternatives.
First, contact InnerActive telling them to fix their software. It's their responsibility.
Meanwhile, if you know how to reproduce the problem, you can try following. Subscribe for all unhandled exceptions (start with Application.UnhandledException, also there're AppDomain.UnhandledException and TaskScheduler.UnobservedTaskException), in the handler search for “Inneractive.Ad.InneractiveAdControl” in the Exception.StackTrace, if found — ignore the exception, and optionally hide or reload the inneractive banner.
The script is working fine, but when the content ends, the page never reaches to the end. I need to make it stop infinite scrolling when the loaded content is end.
Another question, i dont want to load all the divs right away, i need to load it every five in five, how can i do that?
js:
if($(window).scrollTop() == $(document).height() - $(window).height())
{
$('div#loadmoreajaxloader').show();
$.ajax({
url: "loadmore.php",
success: function(html)
{
if(html)
{
$("#postswrapper").append(html);
$('div#loadmoreajaxloader').hide();
}else
{
$('div#loadmoreajaxloader').html('<center>No more posts to show.</center>');
}
}
});
}
html:
<div id="postswrapper">
<div class="item">content</div>
...
<div id="loadmoreajaxloader" style="display:none;"><center><img src="bigLoader.gif" /></center></div>
</div>
and the loadmore.php contains many <div class="item">content</div>
Ok I'm making 2 assumptions here first that you're calling the code you provided using the scroll listener. Second you might want to call the same code later.
To stop it you need to create a flag so it stop making the calls (or unbind the scroll if you dont want to use the same later), to paginate your results you need to create a variable that count the page you're actually showing but also you need to modify the code processing the ajax request so it uses the page data we're sending.
flag = true; //Flag to identify if the code should request more results
page = 1; //Current page
$(document).scroll(function(){
if(flag && ($(window).scrollTop() == $(document).height() - $(window).height()))
{
$('div#loadmoreajaxloader').show();
$.ajax({
url: "loadmore.php",
data: {page:page}
success: function(html)
{
if(html)
{
$("#postswrapper").append(html);
$('div#loadmoreajaxloader').hide();
page++;
}else
{
flag = false;
$('div#loadmoreajaxloader').html('<center>No more posts to show.</center>');
}
}
});
}
});