亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

AEM Asset API:根據需要創建中間目錄

AEM Asset API:根據需要創建中間目錄

小唯快跑啊 2023-06-14 16:30:01
我正在使用 AEM 6.3。我正在使用 Assets API 通過curl命令上傳資產。我就是這樣做的:curl -i 'http://localhost:4502/api/assets/newFolder' -H "Content-Type: application/json" -d '{"class":"assetFolder","properties":{"title":"New folder"}}' -u admin:admin如果它們不存在,我的用例需要創建中間目錄。是這樣的:curl -i 'http://localhost:4502/api/assets/intermediate1/intermediate2/newFolder' -H "Content-Type: application/json" -d '{"class":"assetFolder","properties":{"title":"New folder"}}' -u admin:admin在上面的示例中,中間件 1 和中間件 2 都不存在。卷曲不起作用,AEM 返回:HTTP/1.1 500 Server ErrorDate: Wed, 21 Aug 2019 14:13:35 GMTX-Content-Type-Options: nosniffX-Frame-Options: SAMEORIGINSet-Cookie: cq-authoring-mode=CLASSIC;Path=/;Expires=Wed, 28-Aug-2019 14:13:35 GMTExpires: Thu, 01 Jan 1970 00:00:00 GMTContent-Type: application/json; charset=UTF-8Transfer-Encoding: chunked{"class":["core/response"],"properties":{"path":"/api/assets/intermediate1/intermediate2/newFolder","parentLocation":"/api/assets/intermediate1/intermediate2.json","referer":"","changes":[],"location":"/api/assets/intermediate1/intermediate2/newFolder.json","status.code":500}}500錯誤很奇怪。從日志中我可以看到:21.08.2019 11:13:35.512 *ERROR* [0:0:0:0:0:0:0:1 [1566396815508] POST /api/assets/intermediate1/intermediate2/newFolder HTTP/1.1] com.adobe.granite.rest.impl.servlet.PostRequest Exception during request processing.java.lang.NullPointerException: null    at com.adobe.granite.rest.assets.impl.AssetResourceProvider.getDataPropertyKey(AssetResourceProvider.java:412)也許 AEM Assets API 不支持創建不存在的中間文件夾?也許 500 錯誤只是一個錯誤?
查看完整描述

1 回答

?
至尊寶的傳說

TA貢獻1789條經驗 獲得超10個贊

有 2 個選項可以使用資產 API。您可以嘗試以下任何一項:

下面的示例顯示了在資產層次結構中創建 2 個新文件夾。

選項1

curl -u admin:admin  http://localhost:4502/api/assets/we-retail/* -F"name=newfolder" -F"title=New Folder"

結果:

{"class":["core/response"],"properties":{"path":"/api/assets/we-retail/*","parentLocation":"/api/assets/we-retail.json","referer":"","isCreate":true,"changes":[{"argument":"/api/assets/we-retail/newfolder","type":"created"}],"location":"/api/assets/we-retail/newfolder.json","status.message":"Created","title":"Content created /api/assets/we-retail/*","status.code":201}}

選項 2

curl -u admin:admin  http://localhost:4502/api/assets/we-retail/newfolder/images -H"Content-Type: application/json" -d "{"class":"assetFolder","properties":{"title":"Images"}}"

結果

{"class":["core/response"],"properties":{"path":"/api/assets/we-retail/newfolder/images","parentLocation":"/api/assets/we-retail/newfolder.json","referer":"","isCreate":true,"changes":[{"argument":"/api/assets/we-retail/newfolder/images","type":"created"}],"location":"/api/assets/we-retail/newfolder/images.json","status.message":"Created","title":"Content created /api/assets/we-retail/newfolder/images","status.code":201}}


命令提示符中默認不識別單引號。將其更改為雙引號應該可以


另一種創建文件夾的方法,強制 primarytype 為整個層次結構的 sling:folder

curl -u admin:admin -Fjcr:primaryType=sling:Folder localhost:4502/content/dam/mFolder/aFolder



查看完整回答
反對 回復 2023-06-14
  • 1 回答
  • 0 關注
  • 187 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號