doukuang1897 2017-07-13 15:06
浏览 98
已采纳

合并两个发布请求中的数据

I have a Rest API that gets the POST requests, data and images comes in two different requests.

/v1/photo # multipart/form-data
/v1/data # json

I'm trying to merge values into Redis

# Save photo
HSET photo:1.jpg file_name 9f7a6775-3815-4d20-affa-e81bc9c4293b
SADD have:uuid photo:1.jpg
HSET photo:2.jpg file_name fcb7db2d-159e-4d0e-b884-ca455bd6f4a5
SADD have:uuid photo:2.jpg

# Save data
HSET photo:1.jpg data JSONsring
SADD have:data photo:1.jpg
HSET photo:2.jpg data JSONsring
SADD have:data photo:2.jpg

Now I need to get all the combined data (In order to save them to another database). I can use sinter to get keys.

SINTER have:uuid have:data

But i need JSON and UUID.

How to make it as quickly and with the minimum spent resources?

  • 写回答

1条回答 默认 最新

  • donglv9813 2017-07-17 19:06
    关注

    For the sake of ensuring this has a marked answer, I'll take the advice of @reticentroot and format the comment into an answer.

    It would be more idiomatic for your POST endpoint to accept the request regardless of whether a corresponding /v1/photo or /v1/data entry has been created. The process that's interfacing with these pieces of data could easily check whether it has both pieces of data, and act accordingly.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 运筹学排序问题中的在线排序
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧