【发布时间】:2012-08-22 01:50:32
【问题描述】:
我想将此作为 Makefile 任务实现:
# step 1:
curl -u username:password -X POST \
-d '{"name": "new_file.jpg","size": 114034,"description": "Latest release","content_type": "text/plain"}' \
https://api.github.com/repos/:user/:repo/downloads
# step 2:
curl -u username:password \
-F "key=downloads/octocat/Hello-World/new_file.jpg" \
-F "acl=public-read" \
-F "success_action_status=201" \
-F "Filename=new_file.jpg" \
-F "AWSAccessKeyId=1ABCDEF..." \
-F "Policy=ewogIC..." \
-F "Signature=mwnF..." \
-F "Content-Type=image/jpeg" \
-F "file=@new_file.jpg" \
https://github.s3.amazonaws.com/
然而,在第一部分中,我需要获取文件大小(以及内容类型,如果这很简单,但不是必需的),所以需要一些变量:
{"name": "new_file.jpg","size": $(FILE_SIZE),"description": "Latest release","content_type": "text/plain"}
我试过了,但它不起作用(Mac 10.6.7):
$(shell du path/to/file.js | awk '{print $1}')
任何想法如何做到这一点?
【问题讨论】:
-
您需要字节大小吗? GNU coreutils
du命令有一个-b选项可以做到这一点; MacOS du 显然没有。注意不要不小心给du输入目录名。