Rist
Rist
CC#
Created by Aquatic Life on 6/11/2023 in #help
❔ Difficulties with http requests for image(blob) column in mysql
yeah, that's it
23 replies
CC#
Created by Aquatic Life on 6/11/2023 in #help
❔ Difficulties with http requests for image(blob) column in mysql
that is, image data as an array of bytes
23 replies
CC#
Created by Aquatic Life on 6/11/2023 in #help
❔ Difficulties with http requests for image(blob) column in mysql
You should have a method that takes an image id and returns the data from the database based on that id
23 replies
CC#
Created by Aquatic Life on 6/11/2023 in #help
❔ Difficulties with http requests for image(blob) column in mysql
you can try asking around in #web for more pointers
23 replies
CC#
Created by Aquatic Life on 6/11/2023 in #help
❔ Difficulties with http requests for image(blob) column in mysql
Uploading files is more involved, here's an article about it: https://learn.microsoft.com/en-us/aspnet/core/mvc/models/file-uploads?view=aspnetcore-7.0
23 replies
CC#
Created by Aquatic Life on 6/11/2023 in #help
❔ Difficulties with http requests for image(blob) column in mysql
Pretty sure you can just specify it as an src parameter in img tags
23 replies
CC#
Created by Aquatic Life on 6/11/2023 in #help
❔ Difficulties with http requests for image(blob) column in mysql
Returning a file is pretty simple: once you get your byte[], you can just return in with the built-in File method:
[HttpGet("{id}")]
public async Task<IActionResult> GetImage(int id)
{
var data = await GetImageById(id); // this will be your method for retrieving images
return File(data, "image/jpeg"); // may require a different image type
}
[HttpGet("{id}")]
public async Task<IActionResult> GetImage(int id)
{
var data = await GetImageById(id); // this will be your method for retrieving images
return File(data, "image/jpeg"); // may require a different image type
}
23 replies
CC#
Created by Aquatic Life on 6/11/2023 in #help
❔ Difficulties with http requests for image(blob) column in mysql
What do you want to display to the user?
23 replies
CC#
Created by Aquatic Life on 6/11/2023 in #help
❔ Difficulties with http requests for image(blob) column in mysql
Anyway, that's actually unfeasable
23 replies
CC#
Created by Aquatic Life on 6/11/2023 in #help
❔ Difficulties with http requests for image(blob) column in mysql
Or I guess you could encode them all into base64, making the data payload even larger
23 replies
CC#
Created by Aquatic Life on 6/11/2023 in #help
❔ Difficulties with http requests for image(blob) column in mysql
No, you'd have to do this after the table is filled up by the data, so after all the usings. But your method won't work as it is anyway, unless you aim to return a gigantic pile of data representing your entire collection of saved images in a single response and then parse all of that into actual images with JS or WebAsm.
23 replies
CC#
Created by Aquatic Life on 6/11/2023 in #help
❔ Difficulties with http requests for image(blob) column in mysql
This would probably be much easier if you used EF Core. But as it is right now, I'm assuming the second column in your row will contain an array of bytes, representing the image:
var row = table.Rows[0];
var imageData = row[1] as byte[];
var row = table.Rows[0];
var imageData = row[1] as byte[];
So now the problem is to return this image. You can't just return a whole bunch of them from a single method in asp.net, so you'll probably have to provide an endpoint for requesting images from the database one by one and return them something like this:
return File(imgBytes, "image/jpeg");
return File(imgBytes, "image/jpeg");
23 replies
CC#
Created by rallez on 6/10/2023 in #help
print out all pairs of natural numbers whose sum isequal to the entered number n
and if you use int.TryParse you can display an error message when input isn't an integer
34 replies
CC#
Created by rallez on 6/10/2023 in #help
print out all pairs of natural numbers whose sum isequal to the entered number n
int.Parse also doesn't require using System, but that's not much of an advantage
34 replies
CC#
Created by rallez on 6/10/2023 in #help
print out all pairs of natural numbers whose sum isequal to the entered number n
Convert.ToInt32 will return 0 if the input is null, int.Parse will throw an exception
34 replies
CC#
Created by rallez on 6/10/2023 in #help
print out all pairs of natural numbers whose sum isequal to the entered number n
Also, I'd recommend int.Parse instead of Convert.ToInt32 or even int.TryParse so you can handle invalid input
34 replies
CC#
Created by rallez on 6/10/2023 in #help
print out all pairs of natural numbers whose sum isequal to the entered number n
you can just put i <= n / 2 in you for loop condition
34 replies
CC#
Created by c0nstant on 6/11/2023 in #help
Cannot access file because it's being used by another process
and it's async
12 replies
CC#
Created by c0nstant on 6/11/2023 in #help
Cannot access file because it's being used by another process
You're not awaiting it though
12 replies
CC#
Created by c0nstant on 6/11/2023 in #help
Cannot access file because it's being used by another process
You sure you're not reading the files you just renamed while iterating over the directory? And that you don't have any files open in another program?
12 replies