0
如何在我的收藏中將每張圖像分配到encodeBase64
?動物有很多圖像,圖像屬於動物。Grails使用每個字節的{}收集()
def a = Animal.findAll().collect() { Animal an ->
[id : an.id,
image : an.imagens.caminho.each {(new File(it).bytes.encodeBase64().toString()) }
]
}
在我JSON
只返回路徑,而不是字節。我該如何解決它?
除非我失去了一些東西,你應該能夠簡單地改變'an.imagens.caminho.each'爲'an.imagens.caminho.collect'並獲得預期的行爲。 – 2014-11-07 17:43:24
它的工作感謝 – fsi 2014-11-10 19:30:37
無後顧之憂,作爲答案添加。 – 2014-11-10 19:34:41