Coming Back

Back

Shary File

Shary File

Overview

An API for developers to store their files globally and prevent the headache of S3 integration.

Connect SharyFile to your account to automatically create your bucket and deploy it.

Documentation

1- Activate the tool
2- Go to your profile>apis>SharyFile
3- Create your account in Tigris
4- Access your Dashboard
5- Create a Bucket & Access keys
6- Copy/paste your access key's info
7- Create upload, get, and delete functions.

const token = 'Your API KEY';
const formData = new FormData();
formData.append('file', file);
formData.append('path', `Folder/File's Name`);

const upload = async () => {
    const res = await fetch('https://sharyfile.vercel.app/api', {
        method: 'POST',
        headers: {
            'Authorization': `Bearer ${token}`, 
        },
        body: formData
    });

    const result = await res.json();
    if(result.status === 200){
        //save your file's name in a DB so you can retrieve the file later
        console.log('File Uploaded!');
        return result; 
    }
};

const get = async () => {
    //To get your file's url use '>' instead of '/' in your path
    const res = await fetch("https://sharyfile.vercel.app/api/Folder>File's Name", {
        method: 'GET',
        headers: {
            'Authorization': `Bearer ${token}`, 
        },
    });
    const result = await res.json();
    if(result.status === 200){
        //save your file's name in a DB so you can retrieve the file later
        //Note that this is a signed url and it expires after 1h 
        console.log('Url: ' , result.url);
        return result; 
    }
};

const del = async () => {
    //To get your file's url use '>' instead of '/' in your path
    const res = await fetch("https://sharyfile.vercel.app/api/Folder>File's Name", {
        method: 'DELETE',
        headers: {
            'Authorization': `Bearer ${token}`, 
        },
    });
    const result = await res.json();
    if(result.status === 200){
        //save your file's name in a DB so you can retrieve the file later
        console.log('File deleted!');
        return result; 
    }
};

Details

Shary File

Developer Adam Boukhris

Category Storage

Powered By Tigris

FeedBack

Get started with Shary File