Ask your phone for a file
Send a task with a file input and the recipient uploads a file from the app; your script collects it and saves it to disk.
Good for: pulling a signed PDF back from whoever approved it, grabbing a screenshot or a log off your own phone on demand, any moment a person is the easiest place to get a file from and your script is the easiest place for it to land.
# --save-files downloads each upload into ./inbox as it arrives,
# decrypted and checksum-verified; the emitted JSON line carries the path
sp task --title "Upload the signed contract" --file-input "The signed contract" \
--format json | sp collect --inputs --save-files ./inbox
# fetch a single file again later, by the ids the collect line carried
sp download tsk_0198… inp_0198… --out ./inboximport asyncio
from simplepush import Client, FileUploadInput, TaskCompleted
client = Client(api_token="YOUR_API_TOKEN")
task = client.send_task(
title="Upload the signed contract",
inputs=[FileUploadInput()],
)
async def main():
async for event in task.inputs(timeout=None):
if isinstance(event, TaskCompleted):
for upload in event.uploads:
path = await upload.save("./inbox")
print(f"Saved {path}")
asyncio.run(main())import { Client } from '@simplepush/sdk'
const client = new Client({ apiToken: 'YOUR_API_TOKEN' })
const task = await client.sendTask({
title: 'Upload the signed contract',
inputs: [{ type: 'file', required: true }],
})
for await (const item of task.inputs()) {
if (item.kind === 'taskCompleted') {
for (const upload of item.uploads) {
if (upload.kind === 'file') {
const path = await upload.save('./inbox')
console.log(`Saved ${path}`)
}
}
}
}# Wait: true holds the connection open until the file is uploaded;
# the response body is a presigned download URL, valid for about 5 minutes
URL=$(curl -s -X POST https://api.simplepu.sh/v1/tasks \
-H "API-Token: $SP_API_TOKEN" \
-H "File-Input: Upload the signed contract" \
-H "Wait: true" | tr -d '\n')
curl -s "$URL" -o contract.pdfNo topic means the task goes to your own devices. Add -t (CLI), topic= (Python / TypeScript), or a Topic: header (curl) to ask everyone holding a shared topic, and the first upload completes the wait.
Or let the phone start: submissions
The task above is your script asking. The phone can also just send: tap the FAB button in the Simplepush app to open the submission view. There you can record a voice message, take or photo or select files. A script watching your submissions picks it up in real time.
# --save-files downloads each submission file into ./inbox as it lands,
# decrypted and checksum-verified
sp collect --submissions --save-files ./inbox
# or stop after the first one
sp collect --submissions --save-files ./inbox --until count:1import asyncio
from simplepush import Client
client = Client(api_token="YOUR_API_TOKEN")
async def main():
async for s in client.submissions():
if s.file:
path = await s.file.save("./inbox")
print(f"Saved {path}")
asyncio.run(main())import { Client } from '@simplepush/sdk'
const client = new Client({ apiToken: 'YOUR_API_TOKEN' })
for await (const s of client.submissions()) {
if (s.file) {
const path = await s.file.save('./inbox')
console.log(`Saved ${path}`)
}
}A submission can also carry a photo or an audio clip — check s.photo and s.audio the same way. If your submissions are encrypted, pass your personal password (-p on the CLI, passwords=["..."] in Python, passwords: ['...'] in TypeScript) to decrypt them.