Replies: 2 comments
-
You can build the project simply with just 1 file edit. To get a simplified version of this feature, open /src/pages/api/upload.ts Add the following code right below line 79: " const folderId = req.headers['folder-id'] ? parseInt(req.headers['folder-id'] as string, 10) : null;
if (folderId) {
const userFolder = await prisma.folder.findFirst({
where: {
id: folderId,
userId: user.id,
},
});
if (!userFolder) {
return res.forbidden('Folder does not belong to the user');
}
} Change in line 254: add folderId: folderId const fileUpload = await prisma.file.create({
data: {
name: `${fileName}${compressionUsed ? '.jpg' : `${ext ? '.' : ''}${ext}`}`,
mimetype: req.headers.uploadtext ? 'text/plain' : compressionUsed ? 'image/jpeg' : mimetype,
userId: user.id,
folderId: folderId,
embed: !!req.headers.embed,
password,
expiresAt: expiry,
maxViews: fileMaxViews,
originalName: req.headers['original-name'] ? decodedName ?? null : null,
size: file.size,
},
}); After these changes, you can upload files to a folder by simply adding the folder-id header to the request. To do this, open ShareX custom uploader settings and add the folder-id header to your zipline custom uploader with the value of the folder ID you want to upload to. |
Beta Was this translation helpful? Give feedback.
-
I won't be adding this in v3, but it exists in v4 so please be patient and wait for v4's release in the near future for this feature. |
Beta Was this translation helpful? Give feedback.
-
How can I set a folder for files uploaded via ShareX? Thanks!
Beta Was this translation helpful? Give feedback.
All reactions