Keep Files on Records Private
Attach a file to a record and keep it private, or share it with
select individuals or groups. Previously, all files on records in Lightning Experience were
visible to everyone with access to the record. Now you can choose who sees your file. This
feature is new in Lightning Experience and communities.
Only file owners and administrators have the power to change the value of File Privacy on Records.

This feature is on by default. Just add the File Privacy on Records field to the Files page layout (labeled the Content Version page layout in the Setup menu). After the field is added to the page layout, users see the file privacy field on the file’s detail page and edit panel in Lightning Experience. It also appears in the content detail page and content edit dialog in Salesforce Classic. A file marked as private in Lightning Experience is also private in Salesforce Classic.
Chatter REST API supports private files on records.

