def save_file(uploaded_file, emission_date: str, program: Program):
        uploaded_file.name = "uploaded_" + uploaded_file.name
        uploaded_file_path = settings.FILE_UPLOAD_DIR + uploaded_file.name
        output_file_path = settings.FILE_UPLOAD_DIR + program.get_filename_for_date(
            emission_date)

        if os.path.isfile(uploaded_file_path) or os.path.isfile(
                output_file_path):
            raise FileBeingProcessedException

        upload_service = RemoteService()
        upload_service.check_file_for_date(program.normalized_name(),
                                           emission_date)

        with open(uploaded_file_path, 'wb+') as destination:
            for chunk in uploaded_file.chunks():
                destination.write(chunk)
    def download_archive_file(self, program: Program, emission_date: str):
        filename = program.get_filename_for_date(emission_date)
        archive_url = "http://{}".format(settings.ARCHIVE_SERVER_IP)
        session = requests.Session()
        session.auth = (settings.ARCHIVE_SERVER_USERNAME,
                        settings.ARCHIVE_SERVER_PASSWORD)
        session.post(archive_url)

        r = session.get(archive_url + '/archive/' + program.normalized_name() +
                        "/" + filename,
                        stream=True)

        resp = StreamingHttpResponse(r.iter_content(8096))
        resp['headers'] = "X-Accel-Redirect"
        resp['Content-Disposition'] = 'attachment; filename={}'.format(
            filename)
        resp['Accept-Ranges'] = 'bytes'
        resp['Content-Type'] = 'audio/mpeg'

        return resp