2014-03-04 28 views
1

我试图使用PHP的REST API将内容添加到Adobe的CQ5 DAM。想知道是否有这样的例子,因为我正在努力弄清楚。如何将资产从PHP添加到Adobe的CQ5

+0

这个问题似乎是脱离主题,因为它是关于第三方API – 2014-03-04 01:35:28

回答

3

以下功能将使用PUT方法上载图像,这足以将新资产添加到DAM。

function uploadFile($url, $login, $password, $filePath) { 
     $name = basename($filePath); 
     $fp = fopen($filePath, 'r'); 

     $ch = curl_init(); 
     curl_setopt($ch, CURLOPT_URL, "$url/$name"); 
     curl_setopt($ch, CURLOPT_USERPWD, "$login:$password"); 
     curl_setopt($ch, CURLOPT_PUT, 1); 
     curl_setopt($ch, CURLOPT_INFILE, $fp); 
     curl_setopt($ch, CURLOPT_INFILESIZE, filesize($filePath)); 
     $result = curl_exec($ch); 
     curl_close($ch); 
     fclose($fp); 

     return $result; 
} 

使用范例:

uploadFile('http://localhost:4502/content/dam/geometrixx', 
    'admin', 
    'admin', 
    'my-picture.jpg'); 

/content/dam/geometrixx/my-picture.jpg下创造新的DAM资产。

+0

谢谢,这是最初的伎俩。 –

+0

在本地服务器上运行良好,但是当我尝试将其执行到云服务器时,出现了409冲突错误。服务器上该文件夹中没有其他文件。 –

+0

原来是因为我没有上传到author-sitename.adobeaemcloud.com –

相关问题