사용자가 이미지 파일을 업로드하게하는 간단한 Visualforce 페이지를 작성한 후 파일을 ContentVersion
개체에 저장합니다.Salesforce - ContentVersion의 이미지 파일을 사용자 정의 Visualforce 페이지에 표시 할 수 있습니까?
지금 사용자 지정 Visualforce 페이지에 저장된 이미지를 표시하고 싶습니다. 심지어 가능합니까? <apex:image>
과 같은 모양은 사용할 수 없습니다. 또한 <img href="{!cv.contentVersion}"...>
에는 행운이 없었습니다.
실제 문제는 이미지 파일을 성공적으로 업로드했는데 URL은 무엇입니까? Google 외부에서 임의의 URL로 테스트했는데 이미지를 표시 할 수 있습니다 (예 : /../..some.jpg "). 그러나 업로드 된 이미지 파일의 절대 URL은 무엇인지 알 수 없습니다. contentversion
참고 :. 이것은 내 사용자들은 종종 자신의 사용자 이미지를 변경하려면 이미지를 업로드 할 수 있습니다 정적 자원없는
코드
public with sharing class ImageUploadTestController {
public blob file { get; set; }
public String imageFilePath { get; set; }
public ContentVersion cv { get; set; }
public ImageUploadTestController() {
cv = [select id, versionData, title, pathOnClient FROM ContentVersion limit 1];
}
//fill out the inputFile field and press go. This will upload file to the server
public PageReference go() {
ContentVersion v = new ContentVersion();
v.versionData = file;
v.title = 'some title';
v.pathOnClient ='/foo.jpeg';
insert v;
return new PageReference('/' + v.id);
}
//v.id sample
//069A00000009Ux3
}//end class
없이 VisualForce 페이지
0123.<apex:page controller="ImageUploadTestController">
<apex:form >
<apex:inputFile value="{!file}" />
<apex:commandbutton action="{!go}" value="go"/>
</apex:form>
<!-- none of below works!! :(-->
<a href="/{!cv.id}">{!cv.title} {!cv.pathOnClient}</a>
<a href="https://na7.salesforce.com/069A00000009FG4"></a>
<apex:image value="/069A00000009Ux3" width="220" height="55"/>
</apex:page>
예, 문서 객체에 저장하면됩니다. 단지 단점은 응용 프로그램입니다 다음 문서 테이블에 동료가 시도한만큼의 레코드가있는 경우 패키지 할 수 없습니다. 우리가 쉽게 할 수 있으면 좋겠다 .. –