Re: Django audio recorder Bad request: /record-audio/

2023-03-28 Thread Yong Zu Yi
Thank you for replying me. However, I still get the error Bad request: 
/record-audio/.

Also, I have a question, is it possible that after recording, it will just 
save to the database? Because what I have found that the only way to save 
media files into database is to upload it.

Thanks!

[image: error2.JPG]
On Tuesday, March 28, 2023 at 4:18:54 PM UTC+8 Tega Ukavwe wrote:

> I am currently neck-deep in work, I made the mistake of sending the 
> incorrect screenshot.
> I have corrected it, kindly view the screenshot attached to this email 
> instead.
> Thanks for understanding.
>
> Many Thanks,
> Tega Ukavwe
> Python Like English
>
> On Tue, Mar 28, 2023 at 9:10 AM Tega Ukavwe  wrote:
>
>> Apologies, the previous solution has a mistake in it, on line 27.
>>
>> Kindly refer to the attached screenshot.
>>
>> Thanks,
>> Tega Ukavwe
>> Python Like English
>>
>> On Tue, Mar 28, 2023 at 8:52 AM Tega Ukavwe  wrote:
>>
>>> Hi Yong Zu Yi,
>>>
>>> Based on the screenshot you provided, it looks like you're trying to 
>>> retrieve an audio file from the request's POST data using the 
>>> request.POST dictionary.
>>>
>>> However, audio files should be sent as part of the request's FILES data, 
>>> not POST data.
>>>
>>> To retrieve the audio file from the request's FILES data, you should use 
>>> the request.FILES dictionary instead.
>>>
>>> I have attached a screenshot of a modified code, I first check if the 
>>> audio file is present in the request.FILES dictionary. If it's not 
>>> present, I simply return a 400 Bad Request response. If it's present, 
>>> create a filename based on the current user's username and the current date 
>>> and time, and save the audio file to the server using the open function 
>>> and a for loop to write the file in chunks.
>>>
>>> I hope this helps you solve the issue you were facing. Let me know if 
>>> you have any further questions.
>>>
>>>
>>> Best Wishes,
>>>
>>> Tega Ukavwe
>>>
>>> Python Like English
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d42b52a2-67cd-4618-b048-74623e4cc5cfn%40googlegroups.com.


Django audio recording issue: receiving Bad Request error

2023-03-27 Thread Yong Zu Yi
I am new to Django and also my first time building an application. I am 
building an audio journaling application with Django. 
What I am doing here is a recorder. When user press the recorder button, it 
will direct to record.html with four buttons, Start, Pause, Resume and 
Stop. When the user finished recording and hit the Stop button, it will 
save a audio file (wav). However, I have receive a bad request error and 
the audio file is not created.

I have posted the code at stack overflow:
https://stackoverflow.com/q/75853749/21499403

Can anyone help me please.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4dd18add-5882-4864-ae99-4c079a17f347n%40googlegroups.com.