Questions about file downloads
allmors opened this issue · 0 comments
allmors commented
- windows10
- Hydrogen:latest
Through aircode's upload API, files can be uploaded, but there will be problems with downloading, prompting no such file.
The results are as follows
import aircode from 'aircode';
export default async function (params, content) {
// Get the file from multipart/form-data params, `myFile` is the key
const { _id } = params;
// You can do some permission checks before uploading
// ...
// Upload the file to AirCode
const res = await aircode.files.download({
// Replace the _id value with your file's
_id
});
// return the URL of file
return {
res,
};
}
2023-10-19 Additional information
I still think there is something wrong with using the airecode api for file upload and download in Hydrogen.
If you do not change the data when uploading and saving, only modify the download method as follows
https://github.com/AirCodeLabs/Hydrogen/blob/34d9a016cd7461d4f12ec053399846ad4b925437/src/runtime/file-service.js#L103C7-L103C76
filepath = path.resolve(process.env.AC_FAAS_ROOT, filepath.slice(1));
filepath = process.env.AC_FAAS_ROOT + filepath.slice(2)