I'm trying to use Fine Uploader 5.15.0, set up with multiple file fields & uploader instances (multiple: false is set on each) which all display and select files correctly. They are posting to a custom endpoint that is returning any parameters to me. Uploads are set to happen as soon as the file is selected, and file and QQ parameters are sent okay.
My problem is when I attempt to send additional data to the server along with the upload.
I have tried including my additional parameters in the endpoint of the request option, and as a params node added to the options variously as follows:
uploaders[1] = new qq.FineUploader({
element: document.getElementById("uploader-1"),
multiple: false,
request: {
endpoint: "default.cfm",
paramsInBody: false,
params: {
act: "action/processFile",
uid: 4747
}
}
})
Calls without any parameters available in either form or URL scopes.
Removing the params section and attempting to pass them via endpoint:
request: { endpoint: "default.cfm?act=action/processFile" }
Works fine, but obviously no additional parameters.
request: { endpoint: "default.cfm?act=action/processFile&uid=4747" }
Calls without any URL parameters.
request: { endpoint: "default.cfm?act=action/processFile&uid=4747" }
Calls with "act" available, but all others have their ampersand stripped out, so the parameter name becomes "amp;uid"
According to https://blog.fineuploader.com/include-params-in-the-request-body-or-the-query-string-479ac01cbc63 and other questions on here the first one should work. For the others obviously FineUploader is doing some additional processing on endpoint that is wiping out my parameters.
I'm missing something essential, can anyone educate me?
Thanks!
Related
I have a Laravel backend and a Vue SPA front end. Thus far, I have managed to et the Implicit Grant tokens working. My problem is about the redirection.
After successful authentication, Laravel redirects to http://localhost:8080/auth/callback#access_token=AUTH_TOKEN&token_type=TOKEN_TYPE&expires_in=EXPIRES_IN instead of http://localhost:8080/auth/callback?access_token=AUTH_TOKEN&token_type=TOKEN_TYPE&expires_in=EXPIRES_IN (Note the # and ?). I have to manually type in the correct URL after the successful authentication.
How do I ensure that it's redirected to the correct URL properly in the first place?
Based on this Stack Overflow answer, I managed to find a work around. This feature is not an error and redirecting to myurl.com? doesn't fix the problem. Here is a my solution. In my router index file, I have two entries.
The first is the redirect that the OAuth API returns the token to. The beforeEnter router method gets the URL string, replaces the # with a ? and the next method redirects the app to the save route.
The indexOf method gets the index of the ? in the newly formated url and passes it to the substring method which truncates the http(s):// part so that this solution is adaptable to both http and https.
The truncation results in ?access_token. This is then appended to the next method path entry and as a result, the prop can be accessed from the component at /save via the route.query object.
{
path: `/auth/callback`,
beforeEnter: (to, from, next) => {
let url = window.location.href
if(url.includes('#')) {
let newUrl = url.replace('#', '?');
next({path: `/save${newUrl.substring(newUrl.indexOf('?'))}`})
}
next();
},
},
{
path: `/save`,
component: Auth,
props: (route) => ({
access_token: route.query.access_token
})
},
I use Vuejs to create my frontend for my project.
At the creation of one component ('TimeCapsy.vue'), I make an AJAX call to my backend like this:
created: function () {
if (verify.verify_login()) {
let token = this.$cookies.get('jwt_us_cas');
let params = {'jwt': token};
console.log(params);
axios({
method: 'post',
url: dev.HOST+'getuserinfoobject',
params: queryString.stringify(params)
})
.then(response => {
console.log(response.data)
})
}
}
As you can see I use the
this.$cookies.get('jwt_us_cas');
to get the a json web token, that I set on the client at the login.
I use the queryString Library to stringify my parameters for my request.
I also tried it without the queryString.stringify(params) call, but I get the same error, e.g. the parameter still turns into null.
When I look at the console log, where I check the params variable, I get this output:
{jwt: "my token comes here"}
So I can see, that it gets the correct value from the cookie.
But when I check the answer from my backend (PHP), I get this error:
Undefined index: jwt in <b>D:\casb\public\index.php</b> on line <b>52</b>
Of course I know that it means, that jwt is null, but I can't understand why.
As I said, right before I make the call I check the params and it shows the token.
I checked the endpoint with Postman and the token as the jwt parameter and it returned a successfull call with the correct answer.
A correct answer is basically just a nested object with some information in it.
My PHP endpoint is pretty basic too:
Router::add('/getuserinfoobject', function () {
$response['response'] = User::getUserInfoObject($_POST['jwt']);
echo json_encode($response);
}, 'post');
So I guess that right before or in my call it nulls my parameter. But I can't understand how, since I make a lot of requests and never had this problem.
From axios docs
params are the URL parameters to be sent with the request
Which means, you should get the value with PHP $_GET.
Or $_REQUEST (which stores both $_GET, $_POST. Also $_COOKIE).
The other hand, you can use data key as docs says
data is the data to be sent as the request body
Only applicable for request methods PUT, POST, and PATCH
So the value would be available in $_POST
axios({
method: 'post',
url: dev.HOST+'getuserinfoobject',
data: {
jwt: token
}
})
I am using the param option in the deleteFile settings to send a temporary ID that I use throughout the page
deleteFile: {
enabled: true,
forceConfirm: false,
method: 'POST',
endpoint: 'myendpoint',
params: {tempID: 'MYFIXEDID'}
},
No post value for tempID is passed in the request. The same syntax works ok for the request settings.
This is confirmed as a bug in version 5.3.2. Request has been opened on the issue tracker.
I have left this question and answer here in case others are having the same issue.
ok.
I'm using Web API to make AJAX requests.
I'm trying to send a PUT request to an action on a controller.
I'm using route attributes.
When I'm sending the data as part of the route data, everything is fine and the action gets the right info.
However, when I'm trying to send the data in the body, I get a 405 status ((Method is not allowed).
I'm also adding the [FromBody] attribute to the parameter. Here's by jQuery call:
type: 'PUT',
url: 'api/ServerQueue/activity',
data: "=2",
success: function (xhr) {
$("#load").hide();
},
error: function () {
$("#load").hide();
}
};
Here's my action:
[Route("status/{status}")]
public string PutStatus([FromBody]int status)
{
}
I placed a "RoutePrefix" on the controller body.
BTW, I'm using VS 2012.
Any idea what could be the source of the problem?
Try changing the route configuration from
[Route("status/{status}")]
to
[Route("status")]
I am a beginner at sencha touch2. i am trying to create a some app which contains a blog view. the code of the blog is given below. when i launch the app, the content fails to load, giving these errors. i am using wamp for localhost.
XMLHttpRequest cannot load " http://secureclick-media-maynemyltf.netdna-ssl.com/Extensions/rjs/c2.js". Origin< http://localhost> is not allowed by Access-Control-Allow-Origin.
XMLHttpRequest cannot load " http://api.yontoo.com/GetClientData.ashx?key=null&id=47a8564d-d089-4195-9564-72f107ea1c56&loc=http%3A//localhost/GS/&apps=bestvideodownloader,ezLooker,pagerage,buzzdock,toprelatedtopics,twittube". Origin <http://localhost> is not allowed by Access-Control-Allow-Origin.
Ext.define('GS.view.blog',
{
extend:'Ext.navigation.View',
xtype: 'blogpanel',
config:{
title: 'Blog',
iconCls: 'star',
items:
{
xtype:'list',
itemTpl:'{title}',
store:
{
autoLoad: true,
fields:['title','author','content'],
proxy:
{
type:'jsonp',
url: 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://feeds.feedburner.com/SenchaBlog',
reader:
{
type:'json',
rootProperty:'responseData.feed.entries',
}
}
}
}
}
});
You're not calling a JSONP service but a JSON one. You can detect it by calling your URL from your browser and see the content isn't starting by a method call.
So you're not bypassing Cross-Domain protections.
You can't just tell the server you want it to answer in JSONP : it must be ready to make such an answer.
And your browser won't let you access from another domain a server answering in json and not having set a header specifying he accepts this cross-domain request. Read this.
EDIT :
You may call this service using JSONP : you just have to specify a callback at the end of the URL.
In addition to this response format, the protocol also supports a
classic JSON-P style callback which is triggered by specifying a
callback argument, which directs the API to deliver the JSON object as
an argument to the specified callback.
Example from the documentation :
'https://ajax.googleapis.com/ajax/services/feed/find?v=1.0&q=Official%20Google%20Blogs&callback=processResults'