# Import Module for QNAP Notes Station export

**URL:** https://discourse.joplinapp.org/t/import-module-for-qnap-notes-station-export/20712
**Category:** Plugins
**Created:** [2 October 2021 15:18 UTC](https://discourse.joplinapp.org/t/import-module-for-qnap-notes-station-export/20712 "2021-10-02T15:18:05Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Mick2nd](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/mick2nd/32/10793_2.png) [@Mick2nd](https://discourse.joplinapp.org/u/Mick2nd)
#### Post date: [2 October 2021 15:18 UTC](https://discourse.joplinapp.org/t/import-module-for-qnap-notes-station-export/20712/1 "2021-10-02T15:18:05Z")

</div>

I'm just implementing an import module. First I implemented the functionality in Python. I used the requests module to access the data api. All worked fine.  
Now I'm trying to convert the implementation to Joplin/Javascript. At the moment I have 2 problems:

1. I got an exception when posting ['auth'] to the data api. ( **there is no function dispatch** ). The same (e.g. /auth) works with curl in Windows Powershell.
2. I cannot post resources as byte arrays with the post method. In Python I got it working. Is there a possibility to do it this way? I want to circumvent the creation of local files and do work with buffers only.  
This is my piece of code where I post the binary content to Joplin:

```auto
	public post_resource = async function(meta_data: any, content: Uint8Array) : Promise<any>
	{
		try
		{
			var title = meta_data['title'];
			var metadata = JSON.stringify(meta_data);
			var metadata_encoded = this.encoder.encode(metadata);
			var data = { props: [null, metadata_encoded], data: [title, content] };
			var resp = await this.post(['resources'], { }, null, data);
		
			return resp;
		}
		catch (e)
		{
			console.error('Exception in Joplin.post_resource: ' + e);
			return { id: 'phantasy.pdf', title: title };
		}
	}

```

Can anyone help?

---

<div class="post-metadata">

### Author: ![roman\_r\_m](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/roman_r_m/32/3297_2.png) [@roman\_r\_m](https://discourse.joplinapp.org/u/roman_r_m)
#### Post date: [2 October 2021 15:55 UTC](https://discourse.joplinapp.org/t/import-module-for-qnap-notes-station-export/20712/2 "2021-10-02T15:55:55Z")

</div>

> [@Mick2nd](#):
>
> I got an exception when posting ['auth'] to the data api. ( **there is no function dispatch** ). The same (e.g. /auth) works with curl in Windows Powershell.

I suppose you don't need to authenticate when your plugin is already running inside Joplin.

---

<div class="post-metadata">

### Author: ![Mick2nd](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/mick2nd/32/10793_2.png) [@Mick2nd](https://discourse.joplinapp.org/u/Mick2nd)
#### Post date: [2 October 2021 16:09 UTC](https://discourse.joplinapp.org/t/import-module-for-qnap-notes-station-export/20712/3 "2021-10-02T16:09:31Z")

</div>

Indeed, it works. Thank you!

---

<div class="post-metadata">

### Author: ![Mick2nd](https://yyz2.discourse-cdn.com/flex028/user_avatar/discourse.joplinapp.org/mick2nd/32/10793_2.png) [@Mick2nd](https://discourse.joplinapp.org/u/Mick2nd)
#### Post date: [3 October 2021 11:27 UTC](https://discourse.joplinapp.org/t/import-module-for-qnap-notes-station-export/20712/4 "2021-10-03T11:27:27Z")

</div>

In the meantime I write the resource to a temp file and provide a path to api. It works. Problem solved!
