• Jonathan Thornton 4
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 5
    Questions
  • 4
    Replies
Hello, I was hoping someone might have some help with an issue I've been struggling with for days. I'm attempting to delete files in Salesforce from AWS S3, which should be easy enough. This is the first time I’ve worked with AWS S3 and there doesn't seem to be a current official SDK or anything that I can find for Salesforce / AWS S3. There’s some deprecated SOAP SDK from 10 years ago but I found another third-party SDK here https://bigassforce.com/aws-sdk (https://bigassforce.com/aws-sdk)which seems to work but here's where I encounter my problem:

The S3 keys are often stored with spaces in them from the Account Name or File Name e.g. Key = ‘<Account.Name> + ‘ ‘ + <Object.Id> + ‘/’ + <filename>’. So something like: ‘Test Account1 012a00000gXQ9nAAG/my picture.jpg’

I don’t know why they were stored this way but it throws an error every time there are spaces in the Key. "Error: The request signature we calculated does not match the signature you provided. Check your key and signing method." No spaces, no problem; I can delete. I’ve tried URIEncoding them, and it may just be the SDK I’m using but that throws the same error as well. Any special characters seems to throw that same error. Am I going about this the wrong way? Should I write it manually via REST? There doesn’t seem to be any examples of how to do this unfortunately that I can find.

Any help is greatly appreciated, thank you!

Jonathan
Hello,

I have a user input field on my Salesforce Community where if a user types someone's name with @NAME it will send the user an email essentially. The controller replaces the "@NAME" with a link to that user's profile page. So what we have is basically a mixture of user input and replaced user input from the controller with html tags in the OutputText. I also have the output replacing the carraige returns with <br/> tags.
 
<apex:outputText value="{!SUBSTITUTE(JSINHTMLENCODE(fi.body), '\r\n', '<br/>')}" escape="false"/>

The problem is the link which comes from the controller gets escaped. A user input of: 

@NAME

123

456

Ends up looking like this:
<a href="www.google.com">@NAME</a>

123

456

I cannot figure out how to display the link properly while still escaping the potentially malicious characters... Any assistance is greatly appreciated!

Here's the relevant controller code for reference if it helps:
if(feeditems != null && feeditems.size() > 0){
			
			for(FeedItem fi : feeditems){
				for(string screenName : screenNames){
					if(fi.body.contains(screenName) && screenNameUserMap.containsKey(screenName)){
						fi.body = fi.body.replace(screenName, '<a href="/FCIProfile?uId=' + screenNameUserMap.get(screenName) + '">' + screenName +'</a>');
					}
				}
			}
		}

Thank you!!
Jonathan
 
Hello,

Has anyone run into anything like this before? I have a modal window that pops up and allows a few depending pick list options and adds those options onto the Custom Object.

It works beautifully on some of our PCs, and others it fails. I figured it was an issue with the browser version or something but I verified that they are all the same. The behavior is the same across Chrome, IE9, FireFox, and Edge.

Any ideas on how I could figure out what's going on here?

Thank you,
Jonathan
Hello everyone,

I'm simply trying to display an address formatted as typed (including carriage returns) into Salesforce on a visualforce page e.g.

As typed:
 
Street Field:         Salesforce Tower
                             415 Mission Street
City:                      San Francisco
State:                    CA           

My requirement is to have it display just like you would expect with the carriage return as typed:

Salesforce Tower
415 Mission Street
San Fracisco, CA

Instead I get:

Salesforce Tower 415 Mission Street
San Francisco, CA

Here is the line of code:
<apex:outputPanel layout="inline" styleclass="block__number" rendered="{!OR(cinfo.RecordType.Name=='Address',cinfo.RecordType.Name=='Phone Number')}">
<apex:outputText escape="false" value="{!IF(cinfo.RecordType.Name=='Address',cinfo.Address__c,cinfo.Phone__c)}"/>
</apex:outputPanel>


Please, any help is greatly appreciated! This should be so simple... Thanks!!

Jonathan
Hello everyone,

I'm simply trying to display an address formatted as typed (including carriage returns) into Salesforce on a visualforce page e.g.

As typed:
 
Street Field:         Salesforce Tower
                              415 Mission Street
City:                      San Francisco
State:                    CA           

My requirement is to have it display just like you would expect with the carriage return as typed:

Salesforce Tower
415 Mission Street
San Fracisco, CA

Instead I get:

Salesforce Tower 415 Mission Street
San Francisco, CA

Here is the line of code:
<apex:outputPanel layout="inline" styleclass="block__number" rendered="{!OR(cinfo.RecordType.Name=='Address',cinfo.RecordType.Name=='Phone Number')}">
<apex:outputText escape="false" value="{!IF(cinfo.RecordType.Name=='Address',cinfo.Address__c,cinfo.Phone__c)}"/>
</apex:outputPanel> 

Please, any help is greatly appreciated! This should be so simple... Thanks!!

Jonathan

Hi, 

I was trying to upload a file to Amazon S3 bucket using the following source code.

public class AmazonFileUpload
{
    public static String uploadFile(Blob body, String name, String contentType, String appUName)
    {
        String uploaded_url;
        try
        {
            if(body != null && String.isNotBlank(name) && String.isNotBlank(contentType))
            {
                String attachmentBody = EncodingUtil.base64Encode(body);
                String formattedDateString = Datetime.now().formatGMT('EEE, dd MMM yyyy HH:mm:ss z');
                String key,secret,bucketname,host,filename,folderName;
                String method = 'PUT';
				key = Amazon_Key__c; //From Custom Settings
                secret =Amazon_Secret__c; //From Custom Settings
                bucketname = Amazon_Bucket_Name__c; //From Custom Settings
                host = Amazon_Host__c; //From Custom Settings
                filename = name; 
                folderName = appUName;
				folderName= folderName.replaceAll( '\\s+', '');
                HttpRequest req = new HttpRequest();
                req.setMethod(method);
                req.setEndpoint('http://' + bucketname + '.' + host + '/' + folderName + '/' + filename);
                req.setHeader('Host', bucketname + '.' + host);
                req.setHeader('Content-Length', String.valueOf(attachmentBody.length()));
                req.setHeader('Content-Encoding', 'UTF-8');
                req.setHeader('Content-type', contentType);
                req.setHeader('Connection', 'keep-alive');
                req.setHeader('Date', formattedDateString);
                req.setHeader('ACL', 'public-read');
                
                Blob blobBody = EncodingUtil.base64Decode(attachmentBody);
                req.setBodyAsBlob(blobBody);
                filename = filename.replaceAll(' ', '');
                String stringToSign = 'PUT\n\n' + contentType + '\n' + formattedDateString + '\n' +  '/' + bucketname +  '/' +folderName + '/' + filename;
                String encodedStringToSign = EncodingUtil.urlEncode(stringToSign, 'UTF-8');
                system.debug('stringToSign='+stringToSign);
                
                Blob mac = Crypto.generateMac('HMACSHA1', blob.valueof(stringToSign),blob.valueof(secret));
                String signed = EncodingUtil.base64Encode(mac);
                String authHeader = 'AWS' + ' ' + key + ':' + signed;
                req.setHeader('Authorization',authHeader);
                String decoded = EncodingUtil.urlDecode(encodedStringToSign, 'UTF-8');
                
               
                Http http = new Http();
                HTTPResponse res = new HTTPResponse();               
                res = http.send(req);               
                String response = res.getBody();
                string url = req.getEndpoint();                
                if(res.getStatus() == 'OK' && res.getStatusCode() == 200)
                {
					 uploaded_url = 'https://'+Label.SIS_Amazon_Host+'/'+Label.SIS_Amazon_Bucket_Name+'/'+folderName+'/'+filename;
                }
                else
                {
                    return res.toString();
                }
            }
            else
            {
                return 'Something wrong happenned while uploading the file, please contact your system administrator.';
            }
        }
        catch(Exception e)
        {
            return 'ERROR: Uploading file to Amazon - '+e.getMessage()+' - '+e.getLineNumber();
        }
		
		return uploaded_url;
    }
}

The above source code is working fine for uploading the document.

But, I want to add one more method to this class, where I can delete an object from S3.

Hi All,
I am getting record types by using below list

List<RecordType> recList= new List<RecordType>([select id, name from recordtype where sobjecttype='obj1__c']);

I want to show this values in apex:select. How can I do this
I tried some ways, but not working.
Please help me

Thanks in Advance!!
Hello everyone,

I'm simply trying to display an address formatted as typed (including carriage returns) into Salesforce on a visualforce page e.g.

As typed:
 
Street Field:         Salesforce Tower
                             415 Mission Street
City:                      San Francisco
State:                    CA           

My requirement is to have it display just like you would expect with the carriage return as typed:

Salesforce Tower
415 Mission Street
San Fracisco, CA

Instead I get:

Salesforce Tower 415 Mission Street
San Francisco, CA

Here is the line of code:
<apex:outputPanel layout="inline" styleclass="block__number" rendered="{!OR(cinfo.RecordType.Name=='Address',cinfo.RecordType.Name=='Phone Number')}">
<apex:outputText escape="false" value="{!IF(cinfo.RecordType.Name=='Address',cinfo.Address__c,cinfo.Phone__c)}"/>
</apex:outputPanel>


Please, any help is greatly appreciated! This should be so simple... Thanks!!

Jonathan
Hello,
I am currently using SFDC's Developer Console (because it's on the cloud) but would like to know the opinion of Developers who have worked with (or may have tried) other IDEs for Force.com.
I have come across various alternative IDEs such as:
  1. MavensMate which is not supported any more (Dec-2017) and the owner suggest to look at "Visual Studio Code Extension";
  2. Visual Studio Code Extension;
  3. Welkin Suite (It looks like a paid option but cannot see the price on their website);
  4. Illuminated Cloud (hosted within JetBrains Intellij IDEA); price seem to be 65 USD for 1 or few licenses (and we never know if the vendor will charge new versions)
  5. The traditional Force.com IDE Eclips based (Free but a real pain to install in a Mac);
  6. Any other IDE?
Could you possible let us know your opinion and if you would advise using one or the other? Maybe you could comment on Pros/Cons for each IDE you know?

Thank you very much.
  • December 03, 2017
  • Like
  • 2
Hello,
I am currently using SFDC's Developer Console (because it's on the cloud) but would like to know the opinion of Developers who have worked with (or may have tried) other IDEs for Force.com.
I have come across various alternative IDEs such as:
  1. MavensMate which is not supported any more (Dec-2017) and the owner suggest to look at "Visual Studio Code Extension";
  2. Visual Studio Code Extension;
  3. Welkin Suite (It looks like a paid option but cannot see the price on their website);
  4. Illuminated Cloud (hosted within JetBrains Intellij IDEA); price seem to be 65 USD for 1 or few licenses (and we never know if the vendor will charge new versions)
  5. The traditional Force.com IDE Eclips based (Free but a real pain to install in a Mac);
  6. Any other IDE?
Could you possible let us know your opinion and if you would advise using one or the other? Maybe you could comment on Pros/Cons for each IDE you know?

Thank you very much.
  • December 03, 2017
  • Like
  • 2