Getting Started

Attention! This is only an interface solution. It means that you will need to launch it on your own preconfigured server.

To start using «File.Shark» media manager it is necessary to do the next things:

  • download archive with files (in this archive you will find index.html file with example of launching media manager, File.Shark Media manager - Documentation.pdf file with documentation, js folder with file.shark.js file, source folder with project source code)
  • include file.shark.js file to your page
  • initialize «File.Shark» media manager (check usage section for more details)
  • configure the server to work with media manager

Setup

Include the file.shark.js file into your page. You can find this file in the archive, in the js folder.

<script src="/js/file.shark.js"></script>

Usage


new Fileshark({
    root: document.getElementById('root'),
    host: 'http://localhost:3500',
    endpoints: {
        folder: '/folder',
        file: '/file'
    },
    headers: {
        'Content-Type': 'application/json'
    },
    onInsertFile: function(data) {
        console.log('data:', data);
    }
});
ParamType and Description
root

Type: HTMLElement

Description: Media manager code will be inserted into this html element.

host

Type: String

Description: Host address for queries.

endpoints

Type: Object

Description: Object with properties where each property is an endpoint url.

endpoints.folder

Type: String

Description: Endpoint for working with folders.

endpoints.file

Type: String

Description: Endpoint for working with files.

headers

Type: Object

Description: Used to send custom headers to the server.

onInsertFile

Type: Function

Description: Callback function needed to insert media file into the post. Since our product is not designed for any particular CMS, you need to determine the way to add a file into the post by yourself.

onInsertFile function receives the object with data about current selected file. This object contains the following properties:

ParamType and Description
id

Type: String

Description: file id

title

Type: String

Description: file title

url

Type: String

Description: file url

description

Type: String

Description: file description

alt

Type: String

Description: file alt text

created

Type: String

Description: file creation date

dimensions

Type: String

Description: file dimensions

extension

Type: String

Description: file extension

size

Type: String

Description: file size

folder

Type: String

Description: id of the folder to which the file belongs

filename

Type: String

Description: real filename

File insertion functionality will not be available if onInsertFile callback function is not defined.

Server

«File.Shark» media manager is only an ui solution at current moment, so you will have to write the server part by yourself. Here you can find the list with request formats that our media manager will send to your server and response format that media manager expects to receive in response.

Folders

This functionality allows you to create, edit and delete folders. If you are sure that you do not need this functionality, you can skip this part and then you will have one folder by default.

  • POST /yourFolderEndpoint - create a new folder

Request parameters:

ParamType and Description
title

Type: String

Description: folder name

Expected response:


    {
        created: "15.10.2018",
        description: "",
        id: "dfd8c3e4-45b3-4278-acba-467b42dae5f9",
        title: "Nature",
        total: "0"
    }
                
ParamType and Description
created

Type: String

Description: creation date

description

Type: String

Description: folder description

id

Type: String

Description: created folder id

title

Type: String

Description: created folder title

total

Type: String

Description: number of files in folder



  • PUT /yourFolderEndpoint - edit folder

Request parameters:

ParamType and Description
title

Type: String

Description: folder name

description

Type: String

Description: folder description

Expected response:


    {
        created: "15.10.2018",
        description: "",
        id: "dfd8c3e4-45b3-4278-acba-467b42dae5f9",
        title: "Nature",
        total: "0"
    }
                
ParamType and Description
created

Type: String

Description: creation date

description

Type: String

Description: folder description

id

Type: String

Description: edited folder id

title

Type: String

Description: edited folder title

total

Type: String

Description: number of files in folder



  • DELETE /yourFolderEndpoint/idOfDeletedFolder - delete folder

No request parameters.

Expected response:

dfd8c3e4-45b3-4278-acba-467b42dae5f9
Type: String
Description: id of deleted folder

Files

This functionality allows you to upload, edit and delete files.

  • GET /yourFileEndpoint - get the list of files

Request parameters:

ParamType and Description
folder

Type: String

Description: current folder id

page

Type: String

Description: current page (offset)

type

Type: String

Description: files extension (from filters)

startDate

Type: String

Description: file creation start date in ISO format (from filters)

endDate

Type: String

Description: file creation end date in ISO format (from filters)

Expected response:


    {
        hasMore: false,
        list: [
            {
                alt: "",
                created: "15.10.2018",
                description: "",
                dimensions: "",
                extension: "zip",
                filename: "favicon_package_v0.16.zip",
                folder: "7f55583d-d42f-4bc3-9853-7f64b93f3c76",
                id: "b713c14b-9fea-49fd-bda7-e4c5e9045a46",
                size: "49.22 KB",
                title: "favicon_package_v0.16.zip",
                url: "http://localhost:3500/assets/images/b713c14b-9fea-49fd-bda7-e4c5e9045a46/file/favicon_package_v0.16.zip"
            }
        ]
    }
                
ParamType and Description
hasMore

Type: String

Description: Determines if there are more files to show. If true then media manager will do a request to get new files when user scrolls to the end of the current file list. If false, there will be no request.

list

Type: String

Description: List of files to be shown.

Each file in the received list should be an object with the following properties:

ParamType and Description
alt

Type: String

Description: alt text if the file is image

created

Type: String

Description: file creation date

description

Type: String

Description: file description

dimensions

Type: String

Description: file dimensions if the file is image

extension

Type: String

Description: file extension

filename

Type: String

Description: real filename

folder

Type: String

Description: the id of folder in which the file was uploaded

id

Type: String

Description: file id

size

Type: String

Description: file size

title

Type: String

Description: file title

url

Type: String

Description: file url



  • POST /yourFileEndpoint - upload file

Request parameters:

ParamType and Description
folder

Type: String

Description: id of the folder in which the file will be uploaded

file

Type: Binary

Description: We use «dropzone.js» library to upload files to the server. Checkout their documentation to handle basic file uploads on the server

Expected response:


    {
        alt: "",
        created: "15.10.2018",
        description: "",
        dimensions: "1200x900",
        extension: "webp",
        filename: "s1.webp",
        folder: "7f55583d-d42f-4bc3-9853-7f64b93f3c76",
        id: "af638588-2e61-4005-915b-f7a6eb22d3b7",
        size: "214.59 KB",
        title: "s1.webp",
        url: "http://localhost:3500/assets/images/af638588-2e61-4005-915b-f7a6eb22d3b7/file/s1.webp"
    }

                
ParamType and Description
alt

Type: String

Description: alt text if the file is image

created

Type: String

Description: file creation date

description

Type: String

Description: file description

dimensions

Type: String

Description: file dimensions if the file is image

extension

Type: String

Description: file extension

filename

Type: String

Description: real filename

folder

Type: String

Description: the id of the folder in which the file was uploaded

id

Type: String

Description: file id

size

Type: String

Description: file size

title

Type: String

Description: file title

url

Type: String

Description: file url



  • PUT /yourFileEndpoint - edit file

Request parameters:

ParamType and Description
title

Type: String

Description: file title

description

Type: String

Description: file description

alt

Type: String

Description: file alt text

Expected response:


    {
        alt: "",
        created: "15.10.2018",
        description: "",
        dimensions: "1200x900",
        extension: "webp",
        filename: "s1.webp",
        folder: "7f55583d-d42f-4bc3-9853-7f64b93f3c76",
        id: "af638588-2e61-4005-915b-f7a6eb22d3b7",
        size: "214.59 KB",
        title: "s1.webp",
        url: "http://localhost:3500/assets/images/af638588-2e61-4005-915b-f7a6eb22d3b7/file/s1.webp"
    }

                
ParamType and Description
alt

Type: String

Description: alt text if the file is image

created

Type: String

Description: file creation date

description

Type: String

Description: file description

dimensions

Type: String

Description: file dimensions if the file is image

extension

Type: String

Description: file extension

filename

Type: String

Description: real filename

folder

Type: String

Description: the id of the folder in which the file was uploaded

id

Type: String

Description: file id

size

Type: String

Description: file size

title

Type: String

Description: file title

url

Type: String

Description: file url



  • DELETE /yourFileEndpoint/idOfDeletedFile - delete file

No request parameters.

Expected response:

dfd8c3e4-45b3-4278-acba-467b42dae5f9
Type: String
Description: id of deleted file

Browsers support

BrowserVersions
Chromelast 10 versions
Firefoxlast 10 versions
Operalast 5 versions
Safarilast 4 versions
Edgelast 3 versions
IE11