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".
- Host: GitHub
- URL: https://github.com/ronaldaug/import-collection
- Owner: ronaldaug
- Created: 2021-09-03T08:25:32.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-04-03T01:59:49.000Z (about 3 years ago)
- Last Synced: 2025-02-17T04:01:31.559Z (3 months ago)
- Language: PHP
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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)
})
})
```