public function testResponse()
 {
     $response = Transloadit::response();
     $this->assertEquals(false, $response);
     $data = array('foo' => 'bar');
     $_POST['transloadit'] = json_encode($data);
     $response = Transloadit::response();
     $this->assertInstanceOf('transloadit\\TransloaditResponse', $response);
     $this->assertEquals($data, $response->data);
     // Can't really test the $_GET['assembly_url'] case because of PHP for now.
 }
 public function redirectUpload()
 {
     sleep(15);
     $response = Transloadit::response();
     if ($response) {
         if (!empty($response->data['results'])) {
             $respon = $response->data['results']['upload'][0];
             $server = $response->data['fields']['server'];
             $tipe = $response->data['fields']['tipe'];
             $file = File::create(['namafile' => $respon['name'], 'size' => $respon['size'], 'url' => $respon['url'], 'server' => $server, 'status' => 0, 'tipe' => $tipe, 'idteam' => Auth::user()->team->id]);
             $job = $this->dispatch(new DownloadFileFromTransloadit($file));
             return redirect('/user/upload')->with('message', 'Upload file berhasil');
         } else {
             return redirect('/user/upload')->with('error', 'Upload gagal, silahkan cek kembali file anda');
         }
     }
     return redirect()->away(Request::url());
 }
<?php

$config = (require __DIR__ . '/config/common.php');
use transloadit\Transloadit;
$transloadit = new Transloadit($config);
/*
### 2. Create a simple end-user upload form

This example shows you how to create a simple transloadit upload form
that redirects back to your site after the upload is done.

Once the script receives the redirect request, the current status for
this assembly is shown using Transloadit::response().

Note: There is no guarantee that the assembly has already finished
executing by the time the `$response` is fetched. You should use
the `notify_url` parameter for this.
*/
// Check if this request is a transloadit redirect_url notification.
// If so fetch the response and output the current assembly status:
$response = Transloadit::response();
if ($response) {
    echo '<h1>Assembly status:</h1>';
    echo '<pre>';
    print_r($response);
    echo '</pre>';
    exit;
}
// This should work on most environments, but you might have to modify
// this for your particular setup.
$redirectUrl = sprintf('http://%s%s', $_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI']);
 /**
  * Handle song submission
  *
  * @return Response
  */
 public function upload()
 {
     $rules = array('song' => 'max:61440');
     $validation = Validator::make(Input::all(), $rules);
     if ($validation->fails()) {
         return Response::make($validation->errors->first(), 400);
     }
     $file = Input::file('song');
     if (count($file) > 0) {
         $extension = $file->getClientOriginalExtension();
         $directory = public_path() . '/uploads/' . sha1(time());
         $filename = sha1(time() . time()) . ".{$extension}";
         $name = $file->getClientOriginalName();
         $upload_success = $file->move($directory, $filename);
         if ($upload_success) {
             $song = new Song();
             $song->path = $directory;
             $song->original_name = $filename;
             $song->artist = Auth::user()->id;
             $song->title = $name;
             $song->save();
             Session::put('song', $song->id);
             // Generating waveform
             $transloadit = new Transloadit(array('key' => '8b6e8f905c0811e4b45af39f2111cd0b', 'secret' => '75b297187e5676cb0e4b6ac12b11ba550bb51082'));
             $response = $transloadit->createAssembly(array('files' => array($directory . "/" . $filename), 'wait' => true, 'params' => array('steps' => array('mp3' => array('robot' => '/audio/encode', 'preset' => "mp3", 'result' => true, 'ffmpeg' => array('ss' => "00:00:00.0", 't' => "00:00:30")), 'waveform' => array('robot' => "/audio/waveform", 'use' => ":original", 'width' => 295, 'height' => 55, 'background_color' => "ffffffff", 'outer_color' => "607BA9aa", 'center_color' => "607BA9aa", 'result' => true)), 'notify_url' => URL::to('/') . '/notify')));
             $assembly = $response->data['assembly_id'];
             $a = new Assembly();
             $a->assembly = $assembly;
             $a->song = $song->id;
             $a->save();
         }
         if ($upload_success) {
             return Response::json('success', 200);
         } else {
             return Response::json('error', 400);
         }
     } else {
         return Response::json('error', 400);
     }
 }