S
S
sevic2021-11-17 20:17:59
AJAX
sevic, 2021-11-17 20:17:59

How can a client handle a 403 server response to a file request, such as an image?

The user requests a file via api (picture, audio, video ...), let's say he does not have access to some files - on the server I check the permissions to access the files of this user and if there is no permission to the file, then I send 403.
User and so sees only those files to which there is access.
Let's assume the following case: one user sends a private file in a message to the second user, this second user has access to this file in the message, but then the first user decides to deny access to the second user to the file. The file can simply not be requested from the server and not displayed in the message if access is denied, but I want to show some kind of stub, something like the inscription or image "Access to the file is closed." Before showing the file, make an ajax request: if 200 then show the corresponding content of the file, if 403, then show a stub?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question