notebook-examples/share_file.ipynb

95 lines
2.3 KiB
Plaintext
Raw Permalink Normal View History

2024-06-12 14:49:56 +00:00
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
2024-06-14 10:58:25 +00:00
"*this notebook works in any Sandbox environments* "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Sharing files on the Sandbox Platform\n",
"### Using Share UI\n",
"\n",
"for non technical users an interactive webservice is provided. [ShareUI](https://share.sandbox.iuk.hdm-stuttgart.de/admin). \n",
"\n",
"![ShareUI](https://gist.github.com/assets/634470/f90a0c03-8834-4685-95ca-a73e98cabc2f)\n",
"\n",
"### Example CLI Share (Headless) File Upload\n",
2024-06-13 15:12:15 +00:00
"The following example provides a code snippet for sharing a file via cli share. The CLI Endpoint is only avaiable from the Sandbox.\n",
2024-06-14 10:58:25 +00:00
"#### Using Python"
2024-06-12 14:49:56 +00:00
]
},
{
"cell_type": "code",
2024-06-13 15:12:15 +00:00
"execution_count": 4,
2024-06-12 14:49:56 +00:00
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"uploading file\n",
2024-06-13 15:12:15 +00:00
"<Response [403]> Forbidden\n"
2024-06-12 14:49:56 +00:00
]
}
],
"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)"
]
2024-06-13 15:12:15 +00:00
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2024-06-14 10:58:25 +00:00
"#### Using Curl\n"
2024-06-13 15:12:15 +00:00
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"``` curl -F fileUpload=@doc.zip https://share.storage.sandbox.iuk.hdm-stuttgart.de/upload ```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
2024-06-14 10:58:25 +00:00
"#### Response\n",
2024-06-13 15:12:15 +00:00
"\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"
]
2024-06-12 14:49:56 +00:00
}
],
"metadata": {
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 2
}