我正在開發使用asp.net Web API的restful web服務以在我的Android應用程序中使用它。我正在開發asp.netnet API以在我的Android應用程序中使用它,
,在這裏我所得到的,當我跑我的API
[
{
"id": 41,
"firstName": "ahmed",
"lastName": "jallad",
"gender": "male",
"salary": 6000,
"img": "C:\\Users\\ahmed\\Desktop\\hi.png"
},
{
"id": 46,
"firstName": "ali",
"lastName": "ali",
"gender": "male ",
"salary": 5000,
"img": "C:\\Users\\ahmed\\Desktop\\hi.png"
},
{
"id": 47,
"firstName": "wael",
"lastName": "wael",
"gender": "male",
"salary": 6000,
"img": "C:\\Users\\ahmed\\Desktop\\hi.png"
},
{
"id": 48,
"firstName": "sara",
"lastName": "sara",
"gender": "female",
"salary": 5000,
"img": "C:\\Users\\ahmed\\Desktop\\hi.png"
},
{
"id": 49,
"firstName": null,
"lastName": null,
"gender": null,
"salary": null,
"img": "C:\\Users\\ahmed\\Desktop\\hi.png"
}
]
我存儲圖像的SQL數據庫的路徑,這裏是.NET代碼
public HttpResponseMessage Get(string gender = "ALL")
{
using (EmployeeDBEntities entities = new EmployeeDBEntities())
{
int a = 0;
switch (gender.ToLower())
{
case "all":
return Request.CreateResponse(HttpStatusCode.OK, entities.Employees.ToList());
case "male":
return Request.CreateResponse(HttpStatusCode.OK, entities.Employees.Where(e => e.Gender.ToLower() == "male").ToList());
case "female":
return Request.CreateResponse(HttpStatusCode.OK, entities.Employees.Where(e => e.Gender.ToLower() == "female").ToList());
default:
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, "value for gender must be Male, Femle or ALL. " + gender + " is not valid");
}
}
}
我的問題是我從android應用程序調用時如何從其路徑中打開圖像?
在此先感謝
你真的應該避免在響應返回本地路徑。它不僅不能在其他人的機器上工作,而且還是一個安全漏洞,因爲它會告訴潛在的攻擊者你的機器。相反,首先返回一個URL。 –
https://stackoverflow.com/users/6815131/joe-c –
https://stackoverflow.com/users/6815131/joe-c你有什麼想法如何開始 –