コード例 #1
0
        echo "{$time} 0: metadata already set for '{$target_file}'\n";
        exit(0);
    }
    // download file from irods to tmp
    $localfile = '/tmp/' . basename($target_file);
    if (file_exists($localfile)) {
        unlink($localfile);
    }
    $irodsfile->open("r");
    $str = '';
    while (($buffer = $irodsfile->read(1024 * 1024)) != NULL && connection_status() == 0) {
        $str = $str . $buffer;
    }
    $irodsfile->close();
    file_put_contents($localfile, $str);
    extactExif($localfile, $irodsfile);
    if (file_exists($localfile)) {
        unlink($localfile);
    }
    $time = '[' . date('c') . ']';
    echo "{$time} 0: '{$target_file}' processed!\n";
    exit(0);
} catch (Exception $e) {
    if (file_exists($localfile)) {
        unlink($localfile);
    }
    $time = '[' . date('c') . ']';
    echo "{$time} " . $e->getCode() . ": " . "{$e}";
    exit(-1);
}
function extactExif($localfile, $remoteRODSfile)
コード例 #2
0
ファイル: upload.php プロジェクト: hussamnasir/irods-php
            break;
        }
        $tempuploadfilepath = tempnam(dirname($srcfile['tmp_name']), 'RODS_Web_Upload');
        move_uploaded_file($srcfile['tmp_name'], $tempuploadfilepath);
        //copy($srcfile['tmp_name'], $srcfile['name']);
        $destfile = new ProdsFile($collection->account, $collection->path_str . "/" . $filename);
        /*
        $response=array('success'=> false,'log'=> ''.$collection->account); 
        echo json_encode($response);
        exit(0); 
        */
        $destfile->open('w', $resource);
        $destfile->write(file_get_contents($tempuploadfilepath));
        $destfile->close();
        if (AUTO_EXTRACT_EXIF === true) {
            extactExif($tempuploadfilepath, $destfile);
        }
        $numfiles++;
        unlink($tempuploadfilepath);
    }
    if ($error === false) {
        $response = array('success' => true, 'msg' => "Uploaded file successfully.");
    }
    echo json_encode($response);
} catch (Exception $e) {
    $response = array('success' => false, 'errmsg' => $e->getMessage(), 'errcode' => $e->getCode());
    echo json_encode($response);
}
function extactExif($localfile, $remoteRODSfile)
{
    $exif = exif_read_data($localfile, 'EXIF');