From a26c3042785712b902c03b849359218963e83716 Mon Sep 17 00:00:00 2001 From: Cornelius Specht Date: Wed, 12 Jun 2024 16:49:56 +0200 Subject: [PATCH] add cli_share example --- cli_share_upload_file.ipynb | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 cli_share_upload_file.ipynb diff --git a/cli_share_upload_file.ipynb b/cli_share_upload_file.ipynb new file mode 100644 index 0000000..4836f8c --- /dev/null +++ b/cli_share_upload_file.ipynb @@ -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", + " {\"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 +}