download using ['transloadit']['results']['url']

Archived from the Transloadit support forum. Originally posted on February 2, 2012; details may be outdated, see our docs for current behavior. Original thread

Hey Tranloadit,

I have been trying to setup the robot/sftp to download the converted files, but the ssh configurations are not working as planned for now. It is possible for me to go through all the [‘results’][‘url’] 's from the conversion response and use curl for example to download the resulting converted files via the tmp url?

I’ve tried this, but the issues I encounter is that the tmp url ends with a hash and not with a file extension. Secondly, in the case of photos the tmp url points to a file that does not seem to be the final resulting file, but more like a thumbnail of what the result is supposed to be.

If yes? are there any potential issues with this? scale, number of curls per minute etc? if no? is there another way to get the files that does not involve setting up a special linux group, user and home directory to receive the files from transloadit.

Thanks guys,

Ayuba Audu
Software Engineering
Florida Institute of Technology

Hey Ayuba,

thank you for getting in touch.

I am not I understand why you want to download the files. After all that is what the sftp robot does for you … put the result files where you want them to be on your own server and then make them publicly available using the url_path setting.

Kind regards
Tim

Tim,

My issue is that if I can’t get the robot/sftp to work in time, can I just pull down the files via the [‘transloadit’][‘results’][‘url’]'s and batch download them and switch to the robot/sftp once I have it working?

Sincerely,

Ayuba Audu
Software Engineering
Florida Institute of Technology

Hey Ayuba,

oh sorry, I didn’t understand that.

Yes, you should be able to do that. Instead of curl you could try “wget” which does not need file extensions.

Kind regards
Tim

Tim,

Perfect, lastly is the file extension of each result contained in the [‘transloadit’][‘results’] array? and if not do you have any suggestions about where to get the file extensions to save the wget’s as?

Sincerely,

Ayuba Audu
Software Engineering
Florida Institute of Technology

Hey Ayuba,

when you traverse through the $results array, each entry has a lot of information about the file. Please check that array … it should also have an “ext” key and a “mime” key.

Let me know if that helps.

Hey Ayuba,

did my answer help you?

Tim,

I got the url’s direct download to work via wget. I’m now tying to wrap everything together with your PHP SDK in a nice class with no luck in a certain issue.

I made single file annouce.php that will upload the files using a TransloaditRequest object. Once I run the execute() on the object I thought that by accessing the returned TransloaditResponse->data I would have access to the $results array information in there. But all I get is the curl information. see code below

So my question? is there a way to use the PHP SDK without javascript and upload a file on my sever file system and load the $results on the same page?

`<?php

require_once($_SERVER[DOCUMENT_ROOT].'/dev/tmp/lib/Transloadit.php');


$redirect_url = sprintf(
    'http://%s%s',
    $_SERVER['HTTP_HOST'],
    $_SERVER['REQUEST_URI']
);

$properties = (array(
    'files' => array('0.png'),
    'params' => array(
      'steps' => array(
        'resize' => array(
          'robot' => '/image/resize',
          'width' => 200,
          'height' => 100,
        )
      ),
    'redirect_url' => $redirect_url
    )
));

$t = new TransloaditRequest($properties);

$tr = $t->execute();

if ($tr) {

    //we are in the redirect_url block || we are in the notify_url

    if (!$tr->error()) {

        echo "<pre>";
        print_r($tr->data);
        echo "</pre>";

    } else {

        echo "something went wrong with the request that was sent";

    }

}  else {

    echo "transloadit response failure";

}

?>`

Thanks, -Ayuba

Tim,

I got the url’s direct download to work via wget. I’m now tying to wrap everything together with your PHP SDK in a nice class with no luck in a certain issue.

I made single file `annouce.php` that will upload the files using a `TransloaditRequest` object. Once I run the `execute()` on the object I thought that by accessing the returned `TransloaditResponse->data` I would have access to the `$results` array information in there. But all I get is the `curl` information. **see code below**

So my question? is there a way to use the PHP SDK without javascript and upload a file on my sever file system and load the $results on the same page?

`<?php

require_once($_SERVER[DOCUMENT_ROOT].‘/dev/tmp/lib/Transloadit.php’);

$redirect_url = sprintf(
'http://%s%s',
$_SERVER['HTTP_HOST'],
$_SERVER['REQUEST_URI']
);
$properties = (array(
'files' => array('0.png'),
'params' => array(
'steps' => array(
'resize' => array(
'robot' => '/image/resize',
'width' => 200,
'height' => 100,
)
),
'redirect_url' => $redirect_url
)
));

$t = new TransloaditRequest($properties);

$tr = $t->execute();

if ($tr) {

//we are in the redirect_url block || we are in the notify_url

if (!$tr->error()) {

echo “<pre>”;
print_r($tr->data);
echo “</pre>”;

} else {

echo “something went wrong with the request that was sent”;

}

} else {

echo “transloadit response failure”;

}
?>`

Thanks,
-Ayuba
Sincerely,

Ayuba Audu
Software Engineering
Florida Institute of Technology

So you want to upload a file to transloadit without javascript and have transloadit transfer the results to your server?

Yes, here’s the current work flow.

  1. I upload the raw files to my server
  2. Use transloadit PHP SDK to send the files to transloadit for processing
  3. Using the response from step 2) above and the transloadit PHP SDK get the $results
  4. Grab all the URL’s $results and use wget to download the converted files back to me server.

I hope this helps you help me?

Thanks,

-Ayuba.

Well we also have an SFTP store robot which you could use.
This could simplify this workflow greatly. Have you checked it out already?

Hey Tim,

I’ve tried using the sftp store, but it takes too long for me to get a response back. When I used the sftp store robot the assembly keeps executing infinitely and I never get an “ASSEMBLY_COMPLETED” could you look into this? I’m considering switching to the notify_url if that can respond to me much faster.

Here are the assemblies I’m still waiting on, these same requests without the sftp store took less than 5 seconds.

Assembly REDACTED

Assembly REDACTED

Thanks

Tim,

The assemblies listed above have now been executing for almost 2 hours for a simple resize operation.

If the sftp tool fails, we retry storing your files over sftp 10 times over several hours. That is why it took so long to process.

However, the error could not be recovered and that is why the assembly has been marked as failed and the error is shown on the assembly detail page:

Write failed: Broken pipe
Couldn’t read packet: Connection reset by peer

It seems there was a permission problem. Did you follow our sftp setup instructions from http://transloadit.com/docs/sftp-store closely?

Also check here - it might help: http://askubuntu.com/questions/49271/how-to-setup-a-sftp-server-with-users-chrooted-in-their-homedirectories

Kind regards
Tim

Hey Ayuba,

did you see my reply above?

Closing this for now.