我真的很困惑在ImageView
中显示图像。实际上,当我点击URL
时,我得到了一个文件,而当我在邮递员中访问URL时,又得到了另一件事。当我尝试使用Glide
和其他类似Picasso
之类的东西时,我没有从服务器获取图像。
请建议我我能做些什么。
我的Java服务器代码在这里,您也可以检查它。
@RequestMapping(value = "downloadBlog", method = RequestMethod.GET)
public ResponseEntity<?> downloadBlogImage(@RequestParam(value = "id", required = false) Long id) {
StayHealthyBlog dbFile = checkUserService.findBlogById(id);
return ResponseEntity.ok().contentType(MediaType.parseMediaType(dbFile.getImageType()))
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"xyz" + "\"")
.body(new ByteArrayResource(dbFile.getImageData()));
}
现在如何获取我的图像。
谢谢。
答案 0 :(得分:0)
替换此行:
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_purchase); buyButton = findViewById(R.id.buyButton); product1SKU = getString(R.string.product1SKU); mHelper = new tk.myessentialoils.ideasapp.util.IabHelper(this, getString(R.string.billing64basecode)); mHelper.startSetup(new tk.myessentialoils.ideasapp.util.IabHelper.OnIabSetupFinishedListener() { public void onIabSetupFinished(tk.myessentialoils.ideasapp.util.IabResult result) { if (result.isSuccess()) { Log.d("TAG", "onIabSetupFinished: "); // Hooray, IAB is fully set up! try { mHelper.queryInventoryAsync(mGotInventoryListener); } catch (IabHelper.IabAsyncInProgressException e) { Log.d("TAG","Error querying inventory. Another async operation in progress."); } } else { // Oh no, there was a problem. Log.d("TAG", "Problem setting up In-app Billing: " + result); } } }); }
使用方式:
@RequestMapping(value = "downloadBlog", method = RequestMethod.GET)
更新
确保URL 以@RequestMapping(value = "downloadBlog", method = RequestMethod.GET, produces = MediaType.IMAGE_JPEG_VALUE)
或http://
的{{1}}开头以识别链接协议。
Glide