Skip to content

Instantly share code, notes, and snippets.

View dhaniksahni's full-sized avatar

Dhanik Lal Sahni dhaniksahni

View GitHub Profile
/******************************************************************************
* Author: Dhanik Lal Sahni
* Date: Oct 8, 2019
* Descpription: Implementation class for IServiceRequest to creating Case.
*/
public class CaseServiceRequest implements IServiceRequest{
//validate information
private string validateServiceRequest(ServiceRequestData data){
/******************************************************************************
* Author: Dhanik Lal Sahni
* Date: Oct 8, 2019
* Descpription: Implementation class for IServiceRequest to change account's address.
*/
public class AddressChangeServiceRequest implements IServiceRequest{
//validate information
private string validateServiceRequest(ServiceRequestData data){
/******************************************************************************
* Author: Dhanik Lal Sahni
* Date: Oct 8, 2019
* Descpription: Base Exception for throwing error in code.
*/
public class BaseException extends Exception {
}
/******************************************************************************
* Author: Dhanik Lal Sahni
* Date: Oct 8, 2019
* Descpription: Factory Implementation for creating object.
*/
public class ServiceRequestFactory {
public IServiceRequest getServiceRequest(string serviceRequestType){
/******************************************************************************
* Author: Dhanik Lal Sahni
* Date: Oct 8, 2019
* Descpription: AWS Service for uploading file
*/
public class AWSService {
public string awsKey {get;set;}
public string awsSecret {get;set;}
public class S3Controller {
@AuraEnabled
public static void UploadDocToS3Server(string recordId)
{
UploadDocument(recordId);
}
@future(callout=true)
public static void UploadDocument(string recordId)
{
public class AWSS3Service {
public string awsKey {get;set;}
public string awsSecret {get;set;}
public string bucketName {get;set;}
public string methodName {get;set;}
public string hostName {get;set;}
public AWSS3Service(string key, string secret, string bucket, string method, string host)
{
public class S3Controller {
@AuraEnabled
public static FileData GetS3FileUsingFileId(string recordId)
{
String key = '**************';
String secret = '*********************************';
String bucket = 'salesforcecodex';
String host = 's3-us-west-1.amazonaws.com';
String method = 'GET';
@dhaniksahni
dhaniksahni / ViewAWSFile.cmp
Created January 23, 2020 16:30
Download S3 File In Lighting
<aura:component
controller="S3Controller"
implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction"
access="global">
<aura:attribute name="data" type="String" />
<aura:attribute name="recordId" type="String" />
<aura:attribute name="showFileLink" type="boolean" />
<lightning:button variant="brand" label="View Files" onclick="{!c.getData}" />
<aura:if isTrue="{!v.showFileLink}">
<a href="{!v.data}">Download File</a>
@dhaniksahni
dhaniksahni / S3FileController.apxc
Created January 23, 2020 18:52
Get File Information for S3 Server
public class S3FileController {
@AuraEnabled
public static string getFileUrl(string record)
{
try
{
List<FileStore__c> files=[SELECT S3ServerUrl__c,FileExtension__c FROM FileStore__c
where Id=:record];
FileStore__c file=files[0];
return file.S3ServerUrl__c;