-4

So the story is:

1) I have video files on a server.

2) I allow users to download these files and view them from inside the app.

Problem:

I don't want users to find these video files from outside the app to prevent them from being shared. Because the video files should be paid for to download.

How to do this?

Note: hiding the files is not enough.

Thanks.

Ashley Mills
  • 50,474
  • 16
  • 129
  • 160
data
  • 739
  • 6
  • 17
  • 1
    What part are you trying to stop? Someone downloading them without the app or someone trying to get the file off the device? – Upholder Of Truth Sep 23 '18 at 19:32
  • @UpholderOfTruth someone trying to get the files from the device and sharing it. – data Sep 23 '18 at 19:34
  • Your app will be sandboxed so if you don't make the files accessible they won't be. Just put them somewhere that is not shared within your apps filesystem. – Upholder Of Truth Sep 23 '18 at 19:35
  • Why not just cache them within the application's documents? Something like redis could allow you to store the files in a temp folder on the device that's only accessable by the application. Just don't allow the user on your UI the option to share. And prevent them from recording the screen by adding a black view over the screen if they take a screenshot or attempt to record the screen. Easier said than done I'm sure but that's what I would try. – KSigWyatt Sep 23 '18 at 19:37
  • @UpholderOfTruth I don't know if I am explaining this problem well enough...but in android you can encrypt and decrypt a video file to prevent it from being shared....So you say I dont need encryption in ios? – data Sep 23 '18 at 19:37
  • @KSigWyatt how that will prevent users from finding the video on the file explorer of the device....will it be hidden.......should I do some sort of encryption? – data Sep 23 '18 at 19:40
  • Nope no need to encrypt it just don't make the area accessible outside of your app and the user will never see it. – Upholder Of Truth Sep 23 '18 at 19:40
  • There is no file explorer on iOS – KSigWyatt Sep 23 '18 at 19:41
  • @data there is no file explorer as you are thinking about it that allows you to view the entire devices files. An app can only look within it's own sandbox area and certain public areas (photos, music, etc). It's up to you to make those areas public and even then there is still no central file explorer. – Upholder Of Truth Sep 23 '18 at 19:42
  • @UpholderOfTruth in case of jail breaking thing? Does it still hide them? – data Sep 23 '18 at 19:44
  • That is a possibility so if you are concerned about that you will have to implement your own encryption/decryption or try to detect if the device is jailbroken and refuse to download. – Upholder Of Truth Sep 23 '18 at 19:52
  • @UpholderOfTruth but otherwise no one can find and copy a video file that is sandboxed? – data Sep 23 '18 at 19:53
  • Not if you don't want hem to. – Upholder Of Truth Sep 23 '18 at 19:53
  • @UpholderOfTruth if you mean according to the answer below.....then it quotes that no one can access files as long as the phone is locked.....does this means that when phone is unlocked a user can access? – data Sep 23 '18 at 19:55
  • Your question has nothing to do with iOS or Swift if it is about protecting files you have on a server. – rmaddy Sep 23 '18 at 19:55
  • @rmaddy how you found out that it has nothing to do with ios.....when the question is securing video files on ios? – data Sep 23 '18 at 19:56
  • 1
    @data my comments have nothing to do with that answer or the device being locked/unlocked (which is not being jailbroken). You app is sandboxed regardless of the locked/unlocked state of the device. – Upholder Of Truth Sep 23 '18 at 19:57
  • @UpholderOfTruth thanks alot for your help, sorry for pushing it with the questions....I am an android developer and trying to understand how ios handle stuff. – data Sep 23 '18 at 20:00
  • No problem glad to help – Upholder Of Truth Sep 23 '18 at 20:00
  • @data You state you have files on a server and you don't want anyone to be able to access those files except from your iOS app, correct? So isn't your question about how to ensure only your iOS app can access the files on your server? Isn't this largely about setting up your server correctly and ensuring any request for a file is only coming from your iOS app? There are a lot of comments here. You really need to update your question with all relevant details. – rmaddy Sep 23 '18 at 20:03
  • @rmaddy the question is not about setting security server side...its about securing client-side (ios-side)...any way thanks for the feedback. – data Sep 23 '18 at 20:05
  • Then why is your question talking about having files on a server and downloading them? If none of that is relevant to your issue then remove that info from your question. – rmaddy Sep 23 '18 at 20:08

1 Answers1

3

No other app / browsing one can access the sandbox of another app , if you want to protect your content then store the downloaded videos in a directory where you add this attribute

 func createDirectory(atPath path: String, 
   withIntermediateDirectories createIntermediates: Bool, 
      attributes: [FileAttributeKey : Any]? = nil) throws

NSFileProtectionComplete

The file is stored in an encrypted format on disk and cannot be read from or written to while the device is locked or booting.

See for example the iOS Programming Cookbook:

This is the strongest protection that you can give to your files. By doing so, your app will be able to read from and write to this file as long as the device is unlocked. As soon as the device is locked, you won’t be able to read from or write to the file. When you use this type of protection, free or commercial file system explorers will not be able to read the contents of your files, even if the user’s device is unlocked.

matt
  • 515,959
  • 87
  • 875
  • 1,141
Shehata Gamal
  • 98,760
  • 8
  • 65
  • 87
  • What is meant by as along as the device is unlocked? – data Sep 23 '18 at 19:45
  • do you mean locking the phone screen? – data Sep 23 '18 at 19:47
  • yes , it's phone screen lock/unlock – Shehata Gamal Sep 23 '18 at 19:49
  • how phone screen lock will prevent users from viewing the video outside my app.....what is the relation? – data Sep 23 '18 at 19:51
  • lock/unlock is relevant to read/write from the file , but the important here is that your content is protected – Shehata Gamal Sep 23 '18 at 19:53
  • @Sh_Khan Be careful not to quote without attribution. – matt Sep 23 '18 at 20:00
  • @matt i was about to add that this relevant to Vandad Nahavandipoor 's book ( security chapter) – Shehata Gamal Sep 23 '18 at 20:02
  • I assume that this way of storing wont allow any user or any app that explores files or jail breaking techniques to view my video files....only I can read from my app? – data Sep 23 '18 at 20:03
  • @data What more do you need?? The file is unreadable when the device is locked and is encrypted in any case. Asking over and over won’t change anything. – matt Sep 23 '18 at 20:10
  • To be fair i didn't try it in a jail-Broken device , but for more security you can detect that device with https://stackoverflow.com/questions/6530364/how-to-detect-that-the-app-is-running-on-a-jailbroken-device and prevent the download originally – Shehata Gamal Sep 23 '18 at 20:11
  • @matt I am confused because searching about this...I found out that some questions asked about how to encrypt video files on ios...why didn't they just do what the above answer suggested? – data Sep 23 '18 at 20:12
  • I do not say the answer is right or wrong. I say that your comments just keep asking people to repeat what they have already said. – matt Sep 23 '18 at 20:13