我使用Google搜索了很多,但沒有獲得任何有關Adobe AEM for restfull API的文檔。我嘗試了 https://helpx.adobe.com/experience-manager/using/using-net-client-application.html的.Net代碼。 但它創建的文件夾,而不是上傳內容。 我們需要傳遞什麼參數來上傳任何圖像,mp4,pdf等。下面是我的c#代碼。如何使用.Net的其餘API在Adobe AEM JCR中添加圖像文件
protected void Button1_Click(object sender, EventArgs e)
{
string fileName=FileUpload1.FileName;
String postURL = "http://localhost:4502/content/dam/geometrixx/" + fileName;
System.Uri uri = new System.Uri(postURL);
HttpWebRequest httpWReq = (HttpWebRequest)WebRequest.Create(uri);
NetworkCredential nc = new NetworkCredential("admin", "admin");
httpWReq.Method = "POST";
httpWReq.Credentials = nc;
httpWReq.ContentType = "application/x-www-form-urlencoded";
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] data = FileUpload1.FileBytes;
httpWReq.ContentLength = data.Length;
using (System.IO.Stream stream = httpWReq.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
HttpWebResponse response = (HttpWebResponse)httpWReq.GetResponse();
string responseText = string.Empty;
using (var reader = new System.IO.StreamReader(response.GetResponseStream(), encoding))
{
responseText = reader.ReadToEnd();
}
TextBox1.Text = responseText;
}
我沒有規定使用捲曲。有沒有可能給一個例子上傳資產使用簡單的JavaScript? –
您的問題與JavaScript和客戶端代碼執行無關。如果你仍然需要通過JS上傳文件,你可以檢查[這個鏈接](http://blog.teamtreehouse.com/uploading-files-ajax)。您要求的是如何使用AEM Rest API上傳文件,我認爲我給了您所需的一切。你有網址,方法和解釋。 – d33t