Ejemplo n.º 1
0
function verifyFileInS3($includeThumbnail)
{
    global $expectedMaxSize;
    $bucket = $_POST["bucket"];
    $key = $_POST["key"];
    // If utilizing CORS, we return a 200 response with the error message in the body
    // to ensure Fine Uploader can parse the error message in IE9 and IE8,
    // since XDomainRequest is used on those browsers for CORS requests.  XDomainRequest
    // does not allow access to the response body for non-success responses.
    if (getObjectSize($bucket, $key) > $expectedMaxSize) {
        // You can safely uncomment this next line if you are not depending on CORS
        //header("HTTP/1.0 500 Internal Server Error");
        deleteObject();
        echo json_encode(array("error" => "File is too big!"));
    } else {
        $link = getTempLink($bucket, $key);
        $response = array("tempLink" => $link);
        if ($includeThumbnail) {
            $response["thumbnailUrl"] = $link;
        }
        echo json_encode($response);
    }
}
Ejemplo n.º 2
0
function verifyFileInS3($includeThumbnail)
{
    global $expectedMaxSize;
    $bucket = $_REQUEST["bucket"];
    $key = $_REQUEST["key"];
    // If utilizing CORS, we return a 200 response with the error message in the body
    // to ensure Fine Uploader can parse the error message in IE9 and IE8,
    // since XDomainRequest is used on those browsers for CORS requests.  XDomainRequest
    // does not allow access to the response body for non-success responses.
    if (isset($expectedMaxSize) && getObjectSize($bucket, $key) > $expectedMaxSize) {
        // You can safely uncomment this next line if you are not depending on CORS
        header("HTTP/1.0 500 Internal Server Error");
        deleteObject();
        echo json_encode(array("error" => "File is too big!", "preventRetry" => true));
    } else {
        $link = getTempLink($bucket, $key);
        $metadata = getMetaData($bucket, $key);
        $size = getObjectSize($bucket, $key);
        $lastmodified = getObjectLastModified($bucket, $key);
        $response = array("link" => $link, "metadata" => $metadata, "key" => $key, "size" => $size, "lastmodified" => date('Y-m-d H:i:s', strtotime($lastmodified)));
        if ($includeThumbnail) {
            $response["thumbnailUrl"] = $link;
        }
        echo json_encode($response);
    }
}