Comments (2)
After much considering, the solution I came up with is the following:
If you are a registered user and upload a file, that file belongs to you. If another user uploads the exact same file, it will also get uploaded and will be attached to that user. That way each user will get a different link. At the same time, if the user uploads the exact same file again, file will be deleted and API will return the original file link instead.
This also applies to anonymous uploads, if the file was anonymously uploaded before and someone attempts to upload the exact same file, they will get the original link instead. This felt the best way to achieve this without over-complicating the logic behind it.
from chibisafe.
Deleting the files is an interesting topic.
Let's take two users, A
and B
.
A uploads file, it's saved on the disk and added to the database, with userid
set to A
.
Application returns:
{
name: 'abc',
...
}
Now B
uploads the same file
. As the hash matches file already existing in the database, application returns the same JSON as above, although the database isn't modified in any way - B
isn't saved as the owner of the file.
Right now the file is accessible by it's filename (https://github.com/WeebDev/loli-safe/blob/master/lolisafe.js#L25 - btwthis line is broken, config.uploads.folder is ignored, that happens not only in this line).
Assuming you solved the first problem by adding many-to-many relation, there's another problem - the file is saved on the disk once, with one filename (abc
). If the user decides to delete it, you need'll to make sure the file is no longer accessible by that name (or else what's the point of deleting the file).
Changing the filename is not an option, it would break existing links used by other users.
Good luck :)
Can't wait to see the progress.
from chibisafe.
Related Issues (20)
- [BUG] "Serve Uploads From" banner does not link to the right place HOT 1
- Snippets on homepage HOT 1
- [BUG]Cannot Read Properties HOT 18
- [FEATURE REQUEST] options to disable Preview generation HOT 1
- [BUG] Caddy reports an error, cannot access port 8001 HOT 10
- [FEATURE REQUEST] Store image thumbnails and video previews in S3 bucket
- [FEATURE REQUEST] Message System HOT 1
- [BUG] Trying to download any file results in 404 HOT 3
- [FEATURE REQUEST] Support MinIO Path-style
- [FEATURE REQUEST] 2 Factor Authentication
- [FEATURE REQUEST] Sub-folders (albums within an album) HOT 1
- [FEATURE REQUEST] Image preview Zoom with mousewheel and move with click+cursor HOT 1
- [FEATURE REQUEST] Sorting files on gallery view or list view by their original names
- [FEATURE REQUEST] community support
- [BUG] Uploads Link Error HOT 1
- [FEATURE REQUEST] Bulk Download of files
- How to change port?
- [FEATURE REQUEST] Add usage metrics for files HOT 1
- [FEATURE REQUEST] Remove the requirement to have a 'Generated Filename Length' for fully customizable urls HOT 2
- [BUG] Getting error when trying to build chibisafe on docker HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chibisafe.