Skip to content

Commit cc13acc

Browse files
authored
chore: adds create item example to README
1 parent 31ec04c commit cc13acc

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

README.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,31 @@ void (async () => {
4242
console.log(items.response.docs)
4343
})()
4444
```
45-
45+
### Create Item (Requires ["S3-Like API Key"](https://archive.org/account/s3.php))
46+
```javascript
47+
import InternetArchive from 'internetarchive-sdk-js'
48+
const { IA_TOKEN } = process.env || {}
49+
const ia = new InternetArchive(IA_TOKEN, { testmode: true })
50+
51+
void (async () => {
52+
const filePath = './generic-image.jpg'
53+
await ia.createItem({
54+
identifier: `generic-image-${Date.now()}`,
55+
collection: 'opensource_image',
56+
mediatype: 'image',
57+
upload: {
58+
filename: 'generic-image.jpg',
59+
path: filePath,
60+
},
61+
metadata: {
62+
title: 'Generic image',
63+
creator: 'Generic creator',
64+
subject: 'generic',
65+
},
66+
})
67+
})()
68+
```
69+
4670
### Update Item (Requires ["S3-Like API Key"](https://archive.org/account/s3.php))
4771
```javascript
4872
import InternetArchive from 'internetarchive-sdk-js'

0 commit comments

Comments
 (0)