【发布时间】:2016-06-03 08:54:00
【问题描述】:
我有一个可读的 NodeJS 流,我想使用它两次。免责声明:我对流不太满意
为什么?
我的服务允许为用户上传图片。我想避免上传相同的图像。
我的工作流程如下:
upload image per ajax
get hash of image
if hash in database
return url from database
else
pass hash to resize&optimize pipeline
upload image to s3 bucket
get hash of image and write it to database with url
return s3 url
我使用hashstream 获取流的哈希值,并使用gm 优化我的图像。
Hashstream 获取一个流,关闭它,创建一个哈希并通过回调返回它。
我的问题是:结合这两种方法的最佳方法是什么?
【问题讨论】: