An open API service indexing awesome lists of open source software.

https://github.com/ronaldaug/import-collection

Cockpit plugin that can import collection data via API. Only accept "json" and "csv".
https://github.com/ronaldaug/import-collection

Last synced: about 1 month ago
JSON representation

Cockpit plugin that can import collection data via API. Only accept "json" and "csv".

Awesome Lists containing this project

README

        

# Cockpit CMS Addon - Import Collection Via Api

Cockpit addon that can import collections data via API. Only accept "json" and "csv" file type.

### Disclaimer
> Most of the code are taken from Cockpit core code [here `import.php`](https://github.com/agentejo/cockpit/blob/b0a2350b099d686b81e9c1b48fffef8845b85939/modules/Collections/Controller/Import.php#L28).

### This is NOT an official addon of Cockpit CMS.

--------

## Installation

- Add this repo ( `import-collection` ) folder inside "addons" folder

--------

### API

- Method - `post`
- Route - `/api/import?token={your_token_goes_here}`

--------

### Parameters

| parameter | type | description |
| ---------- | --------- | ---------------- |
| entries | file | csv or json file |
| collection | string | collection name, this must be the same with the collection name inside Cockpit dashboard |

--------

### Example
```javascript


Import File




Collection Name



Upload


const myForm = document.querySelector('#myForm');
myForm.addEventListener("submit", e => {
e.preventDefault();
let data = new FormData(myForm);
fetch('/api/import?token={your_token_goes_here}', {
method: 'POST',
body: data
}).then(e => e.json()).then(res => {
console.log(res)
})
})


```