Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove the recorded file after uploading is successful #30

Open
nacer-prosysdz opened this issue Mar 14, 2020 · 5 comments
Open

remove the recorded file after uploading is successful #30

nacer-prosysdz opened this issue Mar 14, 2020 · 5 comments

Comments

@nacer-prosysdz
Copy link

nacer-prosysdz commented Mar 14, 2020

hi !

i'm uploading the recorded file manually with :after-recording event, but I want to delete it after the uploading is successfull.

how can i do that ?

@nacer-prosysdz
Copy link
Author

i resolved this by adding ref to <audio-recorder ref="recorder" ...

and after uploading, i call the removeRecord function : this.$refs.recorder.removeRecord();

@karaOdin
Copy link

hi i want to know how you did it and upload it the files please help

@rachediabdenacer
Copy link

rachediabdenacer commented Jun 27, 2020

<audio-recorder
ref="recorder"
:after-recording="afterRecording"
...
...
// define your recordedAudio var
data: () => ({
  recordedAudio: undefined,
  ...
}),
// define your callback function to save data in recordedAudio variable
afterRecording(data) {
  this.recordedAudio = data;
}
// send request to your server side after clicking on upload button
let formData = new FormData();
if (this.recordedAudio && this.recordedAudio.hasOwnProperty('blob') && this.recordedAudio.hasOwnProperty('url') && this.recordedAudio.blob instanceof Blob && !_.isNull(this.recordedAudio.url)) {
  formData.append('record', this.recordedAudio.blob, 'recordedAudio.mp3');
}
// send your http request here

@karaOdin
Copy link

<audio-recorder
ref="recorder"
:after-recording="afterRecording"
...
...
// define your recordedAudio var
data: () => ({
  recordedAudio: undefined,
  ...
}),
// define your callback function to save data in recordedAudio variable
afterRecording(data) {
  this.recordedAudio = data;
}
// send request to your server side after clicking on upload button
let formData = new FormData();
if (this.recordedAudio && this.recordedAudio.hasOwnProperty('blob') && this.recordedAudio.hasOwnProperty('url') && this.recordedAudio.blob instanceof Blob && !_.isNull(this.recordedAudio.url)) {
  formData.append('record', this.recordedAudio.blob, 'recordedAudio.mp3');
}
// send your http request here

well i'm using laravel as backend so i want want to move blob files to a directory so if have any idea or some function handle this and move files to a directory and store it there help me please

@aaarab
Copy link

aaarab commented Dec 9, 2021

hello, very good question Mr @karaOdin :
i think you should use File Storage Laravel libraries.
so this is my solution.
`use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;

class RecordController extends Controller
{
public function store(Request $request)
{

    $file = $request->record;
    //save the mp3 file to 'storage/app/audio' path with fileanme test.wav
    Storage::put('audio/test.mp3', file_get_contents($file));
}

}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants