notebook-examples/cli_share_upload_file.ipynb

81 lines
1.8 KiB
Plaintext

{
"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. The CLI Endpoint is only avaiable from the Sandbox.\n",
"### using python"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"uploading file\n",
"<Response [403]> Forbidden\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)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### using curl\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"``` curl -F fileUpload=@doc.zip https://share.storage.sandbox.iuk.hdm-stuttgart.de/upload ```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Response\n",
"\n",
"The respone of both requests includes the public available download link and the expiration date.\n",
"\n",
"\n",
"``` \n",
" { \"PublicUrl\":\"https://share.storage.sandbox.iuk.hdm-stuttgart.de/upload/14e4d841-4023-4960-b326-1a117e858fad/README.md\",\n",
" \"Size\":93,\n",
" \"Expiration\":\"2024-10-11T00:00:00Z\" }\n",
" ``` \n",
"\n"
]
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 2
}