Last active
November 2, 2017 21:23
-
-
Save obxpete/d23d5aadc51f064d9c2933bbc957738a to your computer and use it in GitHub Desktop.
AWS CloudSearch File/Data upload/update example in ColdFusion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create basic AWS credentials properties | |
BasicAWSCredentials = createObject("java", 'com.amazonaws.auth.BasicAWSCredentials').init(yourAccessKey, YourSecretKey); | |
// turn credentials into a provider object | |
AWSCredentialsProviderObj = createObject("java", "com.amazonaws.auth.AWSStaticCredentialsProvider").init(BasicAWSCredentials); | |
// documents endpoint | |
serviceEndpoint = 'search-mydomain-myendpointstring.us-east-1.cloudsearch.amazonaws.com'; | |
signingRegion = 'us-east-1'; | |
// create our client | |
AmazonCloudSearchDomainClient = createObject("java", "com.amazonaws.services.cloudsearchdomain.AmazonCloudSearchDomainClient").init(BasicAWSCredentials); | |
AmazonCloudSearchDomainClient.setEndpoint(serviceEndpoint); | |
//https://fromraj.wordpress.com/2017/04/03/searching-pdf-content-aws-cloudsearch/ | |
// create a valid stream of files | |
FileName = expandPath('/work/testCloudsearch.json'); | |
inputFile = createObject("java", "java.io.File").init(filename); | |
InputStreamObj = createObject("java", "java.io.FileInputStream").init(inputFile); | |
// create and populate our AWS upload documents request Object | |
uploadDocumentsRequestObj = CreateObject('java', 'com.amazonaws.services.cloudsearchdomain.model.UploadDocumentsRequest').init(); | |
uploadDocumentsRequestObj.setDocuments(InputStreamObj); | |
uploadDocumentsRequestObj.setContentType("application/json"); | |
uploadDocumentsRequestObj.setContentLength(inputFile.length()); | |
// fire away! | |
AmazonCloudSearchDomainClient.uploadDocuments(uploadDocumentsRequestObj); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment