add cli_share example

This commit is contained in:
Cornelius Specht 2024-06-12 16:49:56 +02:00
parent 13a37acd26
commit a26c304278
1 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,48 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example CLI Share (Headless) File Upload\n",
"The following example provides a code snippet for sharing a file via cli share. "
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"uploading file\n",
"<Response [201]> {\"PublicUrl\":\"https://share.storage.sandbox.iuk.hdm-stuttgart.de/upload/14e4d841-4023-4960-b326-1a117e858fad/README.md\",\"Size\":93,\"Expiration\":\"2024-10-11T00:00:00Z\"}\n"
]
}
],
"source": [
"import requests\n",
"\n",
"myurl = 'https://share.storage.sandbox.iuk.hdm-stuttgart.de/upload'\n",
"\n",
"print(\"uploading file\")\n",
"\n",
"files = {\n",
" 'fileUpload':('README.md', open('README.md', 'rb'),'application/octet-stream')\n",
"}\n",
"\n",
"response = requests.post(myurl, files=files)\n",
"print(response,response.text)"
]
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 2
}