Back

The type of file change when upload

  • 0
  • Storage
Sam K
1 May, 2024, 09:28

how are you reading the file? there's a method in node-appwrite https://appwrite.io/docs/references/cloud/server-nodejs/storage#getFilePreview

TL;DR
Developers are trying to upload a physical file from a folder to self-hosted storage using node-appwrite, but after the upload, when trying to open the file via URL in storage, the file displays weird text. The issue could be related to handling the file in buffer format, which may require additional processing depending on its use. Make sure accepted files in the bucket options and permissions are set correctly. Solution: Handle the file according to its preview/download requirements in Node.js. Check the file formats being manipulated in the code, the version compatibility, and verify the file paths.
sukuna7193
1 May, 2024, 09:28

i've also trying with path function also same thing

Sam K
1 May, 2024, 09:28

the path function is for uploading

sukuna7193
1 May, 2024, 09:30

yes i have ready it too it base on this doc that i've write my code so

Sam K
1 May, 2024, 09:31

ok, so after you're doing the upload you can see the actual file in the bucket inside the appwrite console?

sukuna7193
1 May, 2024, 09:32

yes the file is in the storage

Sam K
1 May, 2024, 09:33

now you wanna get the file url for preview/download in nodejs not a browser correct?

Sam K
1 May, 2024, 09:34

if so node-appwrite return the file in buffer format, then depending on what you wanna do with the file (send it to a browser, or store it in the server requesting the file) you have to handle that yourself

Sam K
1 May, 2024, 09:35

is that it?

sukuna7193
1 May, 2024, 09:35

no in fact i have already have the file in a physical folder right ? so im just trying tu send in to the selfhost storage file and the upload is ok... but the problem is on the preview

sukuna7193
1 May, 2024, 09:37

i want tu upload it yo the self hosted and

Sam K
1 May, 2024, 09:37

are you being able to upload the file from your code and after that the file is present in the console?

Sam K
1 May, 2024, 09:38

by console I mean Appwrite console

sukuna7193
1 May, 2024, 09:38

exactly

sukuna7193
1 May, 2024, 09:38

but the content of the is different

Sam K
1 May, 2024, 09:38

so you can mark this task as complete

Sam K
1 May, 2024, 09:39

ok different how?

Sam K
1 May, 2024, 09:40

after uploading the file the content is being different?

Sam K
1 May, 2024, 09:41

after uploading the file what are you seeing in storage in the console same place the screenshot?

sukuna7193
1 May, 2024, 09:42

ok so i have the file imag.jpg that's i on my folder and when you open in my comput the file is open normaly but after upload it usind node-appwrite sdk storage function SelfHoted_storage.createFile( bucket.$id, element.$id, InputFile.fromBuffer(file, ${element.name}) the file content in console have change to �����JFIF���������ICC_PROFILE��������0��mntrRGB XYZ ...... text

sukuna7193
1 May, 2024, 09:42

but if i'm using the sonsole everthing work fine

Sam K
1 May, 2024, 09:42

can you post the code?

Sam K
1 May, 2024, 09:46

I just test it an upload from node-appwrite 12.0.1 and it's working fine

Sam K
1 May, 2024, 09:47

maybe the 8.0 is not forward compatible

sukuna7193
1 May, 2024, 09:51

ok i will try to upgrade the libray and test

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more