
I'm sorry if I did something wrong when I try to upload a file with InputFile.fromPath, but I can't figure what.
I'm on node v.18 and node-appwrite v.13
TypeScript
var sdk = require('node-appwrite');
var fs = require('fs');
const client = new sdk.Client()
.setEndpoint('https://cloud.appwrite.io/v1')
.setProject('<projectID>')
.setSession('');
const storage = new sdk.Storage(client);
storage.createFile(
'<bucketID>',
'unique()',
sdk.InputFile.fromPath('out.png', 'out.png'),
["read('any')"]
);
```
My image is on the same level than my index.js.
... sdk.InputFile.fromPath('out.png', 'out.png'), ^ TypeError: Cannot read properties of undefined (reading 'fromPath')
TypeScript
Many thanks for your help.
TL;DR
Issue: Developers encountering a TypeError when trying to use 'sdk.InputFile.fromPath' to upload a file in a Node.js environment.
Solution: The 'fromPath' method belongs to the 'sdk.File' class, not 'sdk.InputFile'. Change the code to use 'sdk.File.fromPath' instead:
```javascript
sdk.File.fromPath('out.png', 'out.png')
```Recommended threads
- Storage & Database is not allowing.
Storage & Database is not allowing to CRUD after i have logged in ? Using web SDK with next.js without any SSR or node-sdk.
- Privacy settings for storage
In my app the user could upload sensitive images for themselves (as a weight loss journal) and they probably don’t want developers or anyone else but themselves...
- Corrupted files on AWS S3
Hello! I'm having trouble using S3 storage with appwrite for file uploads. It happens when uploading files from the Javascript SDK or from the console. The fi...
