My file cloud API is a set of programming instructions that allow software to interact with my file cloud services. This includes retrieving files from my file cloud, uploading files to my file cloud, and managing files in my file cloud. My file cloud API is designed to work with a variety of programming languages, including Java, Python, and PHP.
- List all files
- Download file
- Upload file
- Search file
- Delete file
Cloning the repo.
git clone https://github.com/horapusa-lk/FileCloudAPI
cd FileCloudAPI
Creating virtual environment
py -m pip install --upgrade pip
py -m pip install --user virtualenv
py -m venv env
Activating virtual environment
.\env\Scripts\activate
install requirements
pip3 install -r requirements.txt
Run main.py
python main.py
GET /listAllFiles
POST /uploadFile
Header | File | Type | Description |
---|---|---|---|
fileName |
- | string |
Required. Name of the file |
- | fileData |
bytes |
Required. File data |
DELETE /deleteFile
Parameter | Type | Description |
---|---|---|
fileId |
int |
Required. Id of the file |
GET /downloadFile
Parameter | Type | Description |
---|---|---|
fileName |
string |
Required. Name of the file |
GET /getFileName
Parameter | Type | Description |
---|---|---|
fileId |
string |
Required. Name of the file |
GET /searchFile
Parameter | Type | Description |
---|---|---|
fileName |
string |
Required. Name of the file |
def upload_file(file_name):
import requests
if "/" in file_name:
file_n = file_name.split("/")[-1]
if "//" in file_name:
file_n = file_name.split("//")[-1]
if "\\" in file_name:
file_n = file_name.split("\\")[-1]
else:
file_n = file_name
x = requests.post(url="http://127.0.0.1:8000/uploadFile", files={"fileFata": open(file_name, 'rb')}, headers={"fileName": file_n})
return x.text
def download_file(file_id):
import requests
file_name = requests.get(url="http://127.0.0.1:8000/getFileName", params={"fileId": file_id})
file = requests.get(url="http://127.0.0.1:8000/downloadFile", params={"fileId": file_id})
print(file.content)
open(file_name.json(), 'wb').write(file.content)
return file_name.text
def list_all_files():
import requests
x = requests.get(url="http://127.0.0.1:8000/listAllFiles")
return x.json()
def search_file(file_name):
import requests
results = requests.get(url="http://127.0.0.1:8000/searchFile", params={"fileName": file_name})
return results.json()