chonk
July 27, 2023, 4:31am
1
When using the --file-local
option in fly m
, the following object is added to the status JSON with the files
array.
{
"guest_path": "guest/path"
"raw_value": "base64 of file content"
}
Adding the files
keyword manually to the API calls under config
didn’t seem to do anything. How was this achieved on the CLI side and can I somehow do the same with the API directly?
andie
July 27, 2023, 12:55pm
2
hey @chonk
When you create or update a Machine with the API, you should be able to add files just like with flyctl commands:
"files": [
{
"guest_path": "string",
"raw_value": "string"
}
If you’re not seeing this work when using this format, then let us know!
1 Like
You found the feature before I could publish the Fresh Produce . We’ll also get the docs updated with details and examples soon!
2 Likes
chonk
July 29, 2023, 6:18am
4
It turns out I SSH’d into the wrong machine to check my file, sorry…
But for people wondering, here is a working example in Python.
import requests
APP_NAME = 'app'
MACHINE_NAME = 'machine'
headers = {
'Authorization': 'Bearer MY_FLY_TOKEN',
}
# run a machine
r = requests.post(
f'https://api.machines.dev/v1/apps/{APP_NAME}/machines',
headers=headers,
json={
'name': MACHINE_NAME,
'config': {
'image': 'alpine',
'processes': [{'cmd': ['sleep', 'infinity']}],
'files': [{'guest_path': '/hello.txt', 'raw_value': 'Z29vZGJ5ZQo='}],
},
},
)
print(r.content)
1 Like
system
Closed
August 5, 2023, 6:18am
5
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.