lundi 29 mars 2021

Could not post value to web API using IFormFile

i have a web application that does an action to upload image to api the code like this

[HttpPost]
public async Task<IActionResult> Upload([FromForm] UploadModel model)
{
    var upload = AccountApi.UploadFile(model);
    return Ok("OK");
}

public static object UploadFile(UploadModel model)
{
    RestClient client = InitClient();
    request.Resource = "Account/UploadFile";
    request.Method = Method.POST;
    request.AddJsonBody(model);
    IRestResponse<object> response = client.Execute<object>(request);
    return response.Data;
}

public class UploadModel
{
    public long UserId { get; set; }
    public string Token { get; set; }
    public IFromFile File { get; set; }
}

and there's a web API to handle Rest request above the code like this

[HttpPost("UploadFile")]
public async Task<object> UploadFileAction(UploadModel model)
{
    // the code handle upload file request here
    return "Success";
}

my issue is the UploadModel model in web application contains the right value that requested from front-end (UserId = 10, Token = "eyJ..........", File = [object]) but when it posted to API, the 3 properties in UploadModel didn't get the value posted from web application (UserId = 0, Token = null, File = null)

could you help me to find the solution for this. Thanks all




initialize client socket in node file that will be sent

I send information to clients from a nodejs server like this :

app.get([...]
    let index = await readFileAsync(path.join(__dirname, 'file.js'), 'utf8');
    res.send(index);
)

I want to initialise a socket in my file.js.

In the socket io documentation, you can do this:

<script src="/socket.io/socket.io.js"></script>
<script>
  var socket = io();
</script>

So I try to copy/paste socket.io.js directly in my file.js and add var socket = io(); at the end, but I got this error on my client : GET http://127.0.0.1:5500/socket.io/?EIO=4&transport=polling&t=NXz6N1S 404 (Not Found)

There is a way to initialize my client socket in the file.js?




Jquery load function don't execute javascript the second time

Well, here is a mysterious problem, i'll explain :

I want to load a page into a div with the jquery load function. In my included file, i have some html, and a js script. My script, in a dom ready, (for test purposes) replace the content of a p balise.

I load this page on a button click event.

When i click it the first time, it all works. When i click the second time, all works, except that the javascript isn't executed.

What i tested :

  • Using dom ready or not (no difference)
  • Removing php in my include file (no difference, and i was desperate lol)
  • Removing success callback function from load method (again, no difference)

index.php (simplified):

<div id="truc">
</div>
<script>
$(function () {
    $('button#test').on('click', function () {    
        $('#truc').load('truc.inc.php');
    });
});
</script>

truc.inc.php :

<div>
    <p id="brebis">Je suis une brebis</p>
</div>

<script>
    $(function () {
        $('#brebis').text($('#brebis').text() + " égarée");
    });
</script>

First time it shows "Je suis une brebis égarée", second time "Je suis une brebis"

Do you guys have an idea ?




dimanche 28 mars 2021

Changing website hyperlink target from link to your choice on your computer [closed]

See in the image as I opened NASA (NASA as an example ). Now if there you see the cursor is in pointer form which on clicking opens another webpage now if I want to change that webpage link like if it opens to any NASA project so I change it adding a photo to my choice only on my computer how can I do it

image of a link in nasa




Click on submit button which does not have an id using selinium

i have tried to click on the submit button using on submit function but i cant see the result, the website i am trying to scrape is

Jntuh

The submit button has the following properties

<input type="submit" value="Submit">

i have used this .execute script

Resultbrowser.execute_script("""document.getElementById("myForm").onsubmit();""")

i dont know if the website has an on submit function

Entire code




How to Configure a Web Audio PannerNode to be Larger than One Point?

How do I configure a PannerNode to be larger than one point?

I have an object that is a right triangle shape, with a bounding box that is 10 by 10. How do I make it so that:

  1. While the listener is approaching any point on the flat side, the sound will be strait from the listener along any point of that side
  2. When the user enters the object the sound will play equally in both speakers while the user is in the object
  3. When the user is outside of the object at the center of the hypotenuse, the sound is coming from multiple directions at once, like forward and right?

I have been looking at the cone attributes (PannerNode.coneInnerAngle, PannerNode.coneOuterAngle, and PannerNode.coneOuterGain), but they look like they only deal with the 1 point size of the sound object and change what direction the sound is facing (like in the Boombox example).

I'm probably misunderstanding how the attributes work, but it doesn't seem as if the Web Audio API allows for multiple sized sound objects.

The only solution I have found, is to calculate the nearest point to the listener, and change the object's position to be that nearest point every time the listener moves. When the listener is inside the object, the sound is positioned at the same location as the user. There are two major problems with this approach:

  1. It is extremely slow updating the nearest point of multiple complex objects.
  2. This approach does not handle sounds coming from multiple sides of the user.

Please let me know what I can do to make sounds larger than one point.

Thank you,




Can i use JNI in a java based web application? If so how to do that?

I am currently working on a project which uses JNI , but i dont know how to exactly do that in a web based application. Anyone help to resolve this.

Thanks in advance!!1