json Pushbullet文件上传示例

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了json Pushbullet文件上传示例相关的知识,希望对你有一定的参考价值。

var page = require('webpage').create();
//viewportSize being the actual size of the headless browser
page.viewportSize = { width: 720, height: 1080 };
//the clipRect is the portion of the page you are taking a screenshot of
page.clipRect = { top: 0, left: 0, width: 720, height: 1080 };
//the rest of the code is the same as the previous example
page.open('http://mevlana-takvimi.appspot.com/home', function() {
//page.open('http://0.0.0.0:8080/home', function() {
  page.render('capture.png');
  phantom.exit();
})


 //http://0.0.0.0:8080/home
#!/usr/bin/env bash
phantomjs << EOF
var page = require('webpage').create();
//viewportSize being the actual size of the headless browser
page.viewportSize = { width: 1024, height: 768 };
//the clipRect is the portion of the page you are taking a screenshot of
page.clipRect = { top: 0, left: 0, width: 1024, height: 768 };
//the rest of the code is the same as the previous example
page.open('http://mevlana-takvimi.appspot.com/home', function() {
  page.render('capture.png');
  phantom.exit();
})
EOF
#!/usr/bin/env bash
TOKEN="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"


# Get upload url
curl --header "Access-Token: ${TOKEN}" \
     --header 'Content-Type: application/json' \
     --data-binary '{"file_name":"capture.png","file_type":"image/png"}' \
     --request POST \
     https://api.pushbullet.com/v2/upload-request > response.json

# Response
cat response.json| json_pp

URL=$(cat response.json | python -c "import json,sys;obj=json.load(sys.stdin);print obj['upload_url'];")

FILE=$(cat response.json | python -c "import json,sys;obj=json.load(sys.stdin);print obj['file_url'];")

# Upload File
curl -i -X POST "${URL}" \
    --header 'Content-Type: application/json' \
    -F file=@capture.png

# gnome-www-browser $FILE

# Generate JSON Payload from template.json
cat template.json | sed "s|FILE|${FILE}|g" > file.json

# Send push notification
curl --header "Access-Token: ${TOKEN}" \
     --header 'Content-Type: application/json' \
     --data-binary @file.json \
     --request POST \
     https://api.pushbullet.com/v2/pushes


{
   "file_name" : "capture.png",
   "title": "Space Travel Ideas",
   "file_url": "FILE",
   "type" : "file",
   "file_type" : "image/png"
}

以上是关于json Pushbullet文件上传示例的主要内容,如果未能解决你的问题,请参考以下文章

python pushbullet_logging.py

Extjs文件上传使用json服务?

将文件中以换行符分隔的 JSON 上传到 BigQuery

如何从 React JS 上传和获取图像到 Json-server?

从jsp页面上传 excel文件 存到数据库 用json做

ios的离子在哪里存储json文件?