TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mohsin Arif
295
6k
137.8k
Delay response while converting Image?
Jun 23 2020 1:37 AM
Hi everyone I have an issue I am making API on .net core when I call data in this there is filed image which return image path, I want to convert it into byte64, when I converted then there is a lot of time to give response below is my code.
I want a response in no time,
var data = await Task.Run(() => context.GetStoreProc.FromSqlRaw(
"EXECUTE dbo.Nstp_GetTeamBy_ID {0}"
, ManagerID).Select(x =>
new
TeamManagerResponse
{
DepartmentName = x.DepartmentName,
DesignationDesc = x.DesignationDesc,
EmailAdd = x.EmailAdd,
EmpImg =
DataHelper.ConvertImageToByteArray(x.EmpImg)
, // below is this method
EmpName = x.EmpName
}).ToListAsync());
return
data;
public
static
string
ConvertImageToByteArray(
string
Image_Path)
{
string
imgPathFinal =
""
;
var imgPath = System.Reflection.Assembly.GetEntryAssembly().Location;
int
location = imgPath.LastIndexOf(
"\\bin"
);
imgPathFinal = imgPath.Substring(0, location) + Image_Path;
byte
[] imageByteArray =
null
;
if
(File.Exists(imgPathFinal))
{
//byte[] result = DataHelper.ConvertImageToByteArray(imgPathFinal);
FileStream fileStream =
new
FileStream(imgPathFinal, FileMode.Open, FileAccess.Read);
using
(BinaryReader reader =
new
BinaryReader(fileStream))
{
imageByteArray =
new
byte
[reader.BaseStream.Length];
for
(
int
i = 0; i < reader.BaseStream.Length; i++)
imageByteArray[i] = reader.ReadByte();
}
return
Convert.ToBase64String(imageByteArray, 0, imageByteArray.Length);
}
else
{
return
imgPathFinal;
}
}
please help me
Reply
Answers (
3
)
Firebase push notification c#
c# search inbox is not workin.