Skip to content

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.

License

Notifications You must be signed in to change notification settings

horapusa-lk/FileCloudAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FileCloudAPI

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.

Features

  • List all files
  • Download file
  • Upload file
  • Search file
  • Delete file

Installation

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 API

Run main.py

  python main.py

API Reference

List all files

  GET /listAllFiles

Upload a file

  POST /uploadFile
Header File Type Description
fileName - string Required. Name of the file
- fileData bytes Required. File data

Delete a file

  DELETE /deleteFile
Parameter Type Description
fileId int Required. Id of the file

Download a file

  GET /downloadFile
Parameter Type Description
fileName string Required. Name of the file

Get file name

  GET /getFileName
Parameter Type Description
fileId string Required. Name of the file

Search file

  GET /searchFile
Parameter Type Description
fileName string Required. Name of the file

Usage/Examples

Upload 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

Download file

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

List all files

def list_all_files():
    import requests
    x = requests.get(url="http://127.0.0.1:8000/listAllFiles")
    return x.json()

Search file

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()

About

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.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages