How do you Require Login for Media Files in Django

It seems to me that the method you outlined in your code should work. It’s really no different than any other protected resource: your views can serve files from disks, records from databases, rendered templates or anything. Just as the login_required decorator prevents unauthorized access to other views, it will prevent such access to your … Read more

How to split video or audio by silent parts

You could first use ffmpeg to detect intervals of silence, like this ffmpeg -i “input.mov” -af silencedetect=noise=-30dB:d=0.5 -f null – 2> vol.txt This will produce console output with readings that look like this: [silencedetect @ 00000000004b02c0] silence_start: -0.0306667 [silencedetect @ 00000000004b02c0] silence_end: 1.42767 | silence_duration: 1.45833 [silencedetect @ 00000000004b02c0] silence_start: 2.21583 [silencedetect @ 00000000004b02c0] silence_end: … Read more

How to create a custom media type (application/vnd) for a RESTful web service?

@JohnDoDo One first question: Does the media type define the contract between my server and client? Yes, media type is one part of the contract. Contract in REST API is not static unlike SOAP(i.e. WSDL). Contract is defined by combination of underlying protocol(i.e. HTTP), URIs and Media Types(it’s not prohibited to use several media types … Read more

How to serve django media files via nginx ?

Here’s a example of how I have my nginx servers setup server { server_name example.com www.example.com; location /static { autoindex on; alias /home/myusername/myproject/static/; } location /media { autoindex on; alias /home/myusername/myproject/media/; } location / { proxy_pass http://127.0.0.1:8000; } } I serve django with Gunicorn on localhost port 8000. (that’s what the proxy_pass is for) The … Read more

How to query Android MediaStore Content Provider, avoiding orphaned images?

Okay, I’ve found the problem with this code sample. In the onCreate() method, I had this line: mImageCursor = managedQuery( MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, projection, selection, selectionArgs, null ); The problem here is that it’s querying for the thumbnails, rather than the actual images. The camera app on HTC devices does not create thumbnails by default, and so … Read more