User Guide Cancel

ColdFusion and Amazon S3

  1. CFML Reference User Guide
  2. ColdFusion functions
    1. ColdFusion functions by category
    2. Functions a-b
      1. Abs
      2. ACos
      3. AddSOAPRequestHeader
      4. AddSOAPResponseHeader
      5. AjaxLink
      6. AjaxOnLoad
      7. ApplicationStop
      8. ArrayAppend
      9. ArrayAvg
      10. ArrayClear
      11. ArrayContains
      12. ArrayContainsNoCase
      13. ArrayDelete
      14. ArrayDeleteAt
      15. ArrayDeleteNoCase
      16. ArrayEach
      17. ArrayFilter
      18. ArrayFind
      19. ArrayFindAll
      20. ArrayFindAllNoCase
      21. ArrayFindNoCase
      22. ArrayInsertAt
      23. ArrayIsDefined
      24. ArrayIsEmpty
      25. ArrayLen
      26. ArrayMap
      27. ArrayMax
      28. ArrayMin
      29. ArrayNew
      30. ArrayPrepend
      31. ArrayReduce
      32. ArrayResize
      33. ArraySet
      34. ArraySetMetadata
      35. ArraySlice
      36. ArraySort
      37. ArraySum
      38. ArraySwap
      39. ArrayToList
      40. Asc
      41. ASin
      42. Atn
      43. AuthenticatedContext
      44. AuthenticatedUser
      45. BinaryDecode
      46. BinaryEncode
      47. BitAnd
      48. BitMaskClear
      49. BitMaskRead
      50. BitMaskSet
      51. BitNot
      52. BitOr
      53. BitSHLN
      54. BitSHRN
      55. BitXor
      56. BooleanFormat
    3. Functions-c-d
      1. CacheGet
      2. CacheGetAllIds
      3. CacheGetMetadata
      4. CacheGetProperties
      5. CacheGetSession
      6. CacheIdExists
      7. CachePut
      8. CacheRegionExists
      9. CacheRegionNew
      10. CacheRegionRemove
      11. CacheRemove
      12. CacheRemoveAll
      13. CacheSetProperties
      14. CallStackDump
      15. CallStackGet
      16. CanDeSerialize
      17. Canonicalize
      18. CanSerialize
      19. Ceiling
      20. CharsetDecode
      21. CharsetEncode
      22. Chr
      23. CJustify
      24. Compare
      25. CompareNoCase
      26. Cos
      27. CreateDate
      28. CreateDateTime
      29. CreateObject
      30. CreateObject: .NET object
      31. CreateObject: COM object
      32. CreateObject: component object
      33. CreateObject: CORBA object
      34. CreateObject: Java or EJB object
      35. CreateObject: web service object
      36. CreateODBCDate
      37. CreateODBCDateTime
      38. CreateODBCTime
      39. CreateSignedJWT
      40. CreateEncryptedJWT
      41. CreateTime
      42. CreateTimeSpan
      43. CreateUUID
      44. CSRFGenerateToken
      45. CSRFVerifyToken
      46. DateAdd
      47. DateCompare
      48. DateConvert
      49. DateDiff
      50. DateFormat
      51. DatePart
      52. DateTimeFormat
      53. Day
      54. DayOfWeek
      55. DayOfWeekAsString
      56. DayOfYear
      57. DaysInMonth
      58. DaysInYear
      59. DE
      60. DecimalFormat
      61. DecodeForHTML
      62. DecodeFromURL
      63. DecrementValue
      64. Decrypt
      65. DecryptBinary
      66. DeleteClientVariable
      67. Deserialize
      68. DeserializeJSON
      69. DeserializeXML
      70. DirectoryCopy
      71. DirectoryCreate
      72. DirectoryDelete
      73. DirectoryExists
      74. DirectoryList
      75. DirectoryRename
      76. DollarFormat
      77. DotNetToCFType
      78. Duplicate
    4. Functions-e-g
      1. EncodeForCSS
      2. EncodeForDN
      3. EncodeForHTML
      4. EncodeForHTMLAttribute
      5. EncodeForJavaScript
      6. EncodeForLDAP
      7. EncodeForURL
      8. EncodeForXML
      9. EncodeForXMLAttribute
      10. EncodeForXpath
      11. Encrypt
      12. EncryptBinary
      13. EntityDelete
      14. EntityLoad
      15. EntityLoadByExample
      16. EntityLoadByPK
      17. EntityMerge
      18. EntityNew
      19. EntityReload
      20. EntitySave
      21. EntityToQuery
      22. Evaluate
      23. Exp
      24. ExpandPath
      25. FileClose
      26. FileCopy
      27. FileDelete
      28. FileExists
      29. FileGetMimeType
      30. FileIsEOF
      31. FileMove
      32. FileOpen
      33. FileRead
      34. FileReadBinary
      35. FileReadLine
      36. FileSeek
      37. FileSetAccessMode
      38. FileSetAttribute
      39. FileSetLastModified
      40. FileSkipBytes
      41. FileUpload
      42. FileUploadAll
      43. FileWrite
      44. FileWriteLine
      45. Find
      46. FindNoCase
      47. FindOneOf
      48. FirstDayOfMonth
      49. Fix
      50. Floor
      51. FormatBaseN
      52. GeneratePBKDFKey
      53. GenerateSecretKey
      54.  GetApplicationMetadata
      55. GetAuthUser
      56. GetBaseTagData
      57. GetBaseTagList
      58. GetBaseTemplatePath
      59. GetClientVariablesList
      60. GetComponentMetaData
      61. GetContextRoot
      62. GetCPUUsage
      63. GetCurrentTemplatePath
      64. GetDirectoryFromPath
      65. GetEncoding
      66. GetException
      67. GetFileFromPath
      68. GetFileInfo
      69. GetFreeSpace
      70. GetFunctionCalledName
      71. GetFunctionList
      72. GetGatewayHelper
      73. GetHttpRequestData
      74. GetHttpTimeString
      75. GetK2ServerDocCount
      76. GetK2ServerDocCountLimit
      77. GetLocale
      78. GetLocaleDisplayName
      79. GetLocalHostIP
      80. GetMetaData
      81. GetMetricData
      82. GetPageContext
      83. GetPrinterInfo
      84. GetPrinterList
      85. GetProfileSections
      86. GetProfileString
      87. GetReadableImageFormats
      88. GetSafeHTML
      89. GetSAMLAuthRequest
      90. GetSAMLLogoutRequest
      91. GenerateSAMLSPMetadata
      92. GetSOAPRequest
      93. GetSOAPRequestHeader
      94. GetSOAPResponse
      95. GetSOAPResponseHeader
      96. GetSystemFreeMemory
      97. GetSystemTotalMemory
      98. GetTempDirectory
      99. GetTempFile
      100. GetTemplatePath
      101. GetTickCount
      102. GetTimeZoneInfo
      103. GetToken
      104. GetTotalSpace
      105. GetUserRoles
      106. GetVFSMetaData
      107. GetWriteableImageFormats
    5. Functions-h-im
      1. Hash
      2. HMac
      3. Hour
      4. HQLMethods
      5. HTMLCodeFormat
      6. HTMLEditFormat
      7. IIf
      8. ImageAddBorder
      9. ImageBlur
      10. ImageClearRect
      11. ImageCopy
      12. ImageCreateCaptcha
      13. ImageCrop
      14. ImageDrawArc
      15. ImageDrawBeveledRect
      16. ImageDrawCubicCurve
      17. ImageDrawLine
      18. ImageDrawLines
      19. ImageDrawOval
      20. ImageDrawPoint
      21. ImageDrawQuadraticCurve
      22. ImageDrawRect
      23. ImageDrawRoundRect
      24. ImageDrawText
      25. ImageFlip
      26. ImageGetBlob
      27. ImageGetBufferedImage
      28. ImageGetEXIFMetadata
      29. ImageGetEXIFTag
      30. ImageGetHeight
      31. ImageGetIPTCMetadata
      32. ImageGetIPTCTag
      33. ImageGetMetadata
      34. ImageGetWidth
      35. ImageGrayscale
      36. ImageInfo
      37. ImageMakeColorTransparent
      38. ImageMakeTranslucent
      39. ImageNegative
      40. ImageNew
      41. ImageOverlay
      42. ImagePaste
      43. ImageRead
      44. ImageReadBase64
      45. ImageResize
      46. ImageRotate
      47. ImageRotateDrawingAxis
      48. ImageScaleToFit
      49. ImageSetAntialiasing
      50. ImageSetBackgroundColor
      51. ImageSetDrawingColor
      52. ImageSetDrawingStroke
      53. ImageSetDrawingTransparency
      54. ImageSharpen
      55. ImageShear
      56. ImageShearDrawingAxis
      57. ImageTranslate
      58. ImageTranslateDrawingAxis
      59. ImageWrite
      60. ImageWriteBase64
      61. ImageXORDrawingMode
    6. Functions-in-k
      1. IncrementValue
      2. InputBaseN
      3. Insert
      4. Int
      5. InvalidateOauthAccesstoken
      6. Invoke
      7. InitSAMLAuthRequest
      8. InitSAMLLogoutRequest
      9. InvokeCFClientFunction
      10. IsArray
      11. IsAuthenticated
      12. IsAuthorized
      13. IsBinary
      14. IsBoolean
      15. IsClosure
      16. IsCustomFunction
      17. IsDate
      18. IsDateObject
      19. IsDDX
      20. IsDebugMode
      21. IsDefined
      22. IsImage
      23. IsImageFile
      24. IsInstanceOf
      25. IsIPv6
      26. IsJSON
      27. IsK2ServerABroker
      28. IsK2ServerDocCountExceeded
      29. IsK2ServerOnline
      30. IsLeapYear
      31. IsLocalHost
      32. IsNull
      33. IsNumeric
      34. IsNumericDate
      35. IsObject
      36. isOnline
      37. IsPDFArchive
      38. IsPDFFile
      39. IsPDFObject
      40. IsProtected
      41. IsQuery
      42. isSamlLogoutResponse
      43. isSafeHTML
      44. IsSimpleValue
      45. IsSOAPRequest
      46. IsSpreadsheetFile
      47. IsSpreadsheetObject
      48. IsStruct
      49. IsUserInAnyRole
      50. IsUserInRole
      51. IsUserLoggedIn
      52. IsValid
      53. IsValidOauthAccesstoken
      54. IsWDDX
      55. IsXML
      56. IsXmlAttribute
      57. IsXmlDoc
      58. IsXmlElem
      59. IsXmlNode
      60. IsXmlRoot
      61. JavaCast
      62. JSStringFormat
    7. Functions-l
      1. LCase
      2. Left
      3. Len
      4. ListAppend
      5. ListChangeDelims
      6. ListContains
      7. ListContainsNoCase
      8. ListDeleteAt
      9. ListEach
      10. ListFilter
      11. ListFind
      12. ListFindNoCase
      13. ListFirst
      14. ListGetAt
      15. ListInsertAt
      16. ListLast
      17. ListLen
      18. ListMap
      19. ListPrepend
      20. ListQualify
      21. ListReduce
      22. ListRemoveDuplicates
      23. ListRest
      24. ListSetAt
      25. ListSort
      26. ListToArray
      27. ListValueCount
      28. ListValueCountNoCase
      29. LJustify
      30. Location
      31. Log
      32. Log10
      33. LSCurrencyFormat
      34. LSDateFormat
      35. LSDateTimeFormat
      36. LSEuroCurrencyFormat
      37. LSIsCurrency
      38. LSIsDate
      39. LSIsNumeric
      40. LSNumberFormat
      41. LSParseCurrency
      42. LSParseDateTime
      43. LSParseEuroCurrency
      44. LSParseNumber
      45. LSTimeFormat
      46. LTrim
    8. Functions-m-r
      1. Max
      2. Mid
      3. Min
      4. Minute
      5. Month
      6. MonthAsString
      7. Now
      8. NumberFormat
      9. ObjectEquals
      10. ObjectLoad
      11. ObjectSave
      12. OnWSAuthenticate
      13. ORMClearSession
      14. ORMCloseAllSessions
      15. ORMCloseSession
      16. ORMEvictCollection
      17. ORMEvictEntity
      18. ORMEvictQueries
      19. ORMExecuteQuery
      20. ORMFlush
      21. ORMFlushall
      22. ORMGetSession
      23. ORMGetSessionFactory
      24. ORMIndex
      25. ORMIndexPurge
      26. ORMReload
      27. ORMSearch
      28. ORMSearchOffline
      29. ParagraphFormat
      30. ParameterExists
      31. ParseDateTime
      32. Pi
      33. PrecisionEvaluate
      34. ProcessSAMLResponse
      35. ProcessSAMLLogoutRequest
      36. Quarter
      37. PreserveSingleQuotes
      38. QueryAddColumn
      39. QueryAddRow
      40. QueryConvertForGrid
      41. QueryExecute
      42. QueryFilter
      43. QueryGetResult
      44. QueryGetRow
      45. QueryKeyExists
      46. QueryMap
      47. QueryNew
      48. QueryReduce
      49. QuerySetCell
      50. QuotedValueList
      51. QueryEach
      52. Rand
      53. Randomize
      54. RandRange
      55. ReEscape
      56. REFind
      57. REFindNoCase
      58. ReleaseComObject
      59. REMatch
      60. REMatchNoCase
      61. RemoveCachedQuery
      62. RemoveChars
      63. RepeatString
      64. Replace
      65. ReplaceList
      66. ReplaceNoCase
      67. REReplace
      68. REReplaceNoCase
      69. RestDeleteApplication
      70. RestSetResponse
      71. RestInitApplication
      72. Reverse
      73. Right
      74. RJustify
      75. Round
      76. RTrim
    9. Functions-s
      1. Second
      2. SendGatewayMessage
      3. SendSAMLLogoutResponse
      4. Serialize
      5. SerializeJSON
      6. SerializeXML
      7. SessionInvalidate
      8. SessionRotate
      9. SessionGetMetaData
      10. SessionInvalidate
      11. SessionRotate
      12. SetDay
      13. SetEncoding
      14. SetHour
      15. SetLocale
      16. SetMonth
      17. SetProfileString
      18. SetVariable
      19. SetYear
      20. Sgn
      21. Sin
      22. Sleep
      23. SpanExcluding
      24. SpanIncluding
      25. SpreadsheetAddAutoFilter
      26. SpreadsheetAddColumn
      27. SpreadsheetAddFreezePane
      28. SpreadsheetAddImage
      29. SpreadsheetAddInfo
      30. SpreadsheetAddPageBreaks
      31. SpreadsheetAddRow
      32. SpreadsheetAddRows
      33. SpreadsheetAddSplitPane
      34. SpreadsheetCreateSheet
      35. SpreadsheetDeleteColumn
      36. SpreadsheetDeleteColumns
      37. SpreadsheetDeleteRow
      38. SpreadsheetDeleteRows
      39. SpreadsheetFormatCell
      40. SpreadsheetFormatColumn
      41. SpreadsheetFormatCellRange
      42. SpreadsheetFormatColumn
      43. SpreadsheetFormatColumns
      44. SpreadsheetFormatRow
      45. SpreadsheetFormatRows
      46. SpreadsheetGetCellComment
      47. SpreadsheetGetCellFormula
      48. SpreadsheetGetCellValue
      49. SpreadsheetGetColumnCount
      50. SpreadsheetInfo
      51. SpreadsheetMergeCells
      52. SpreadsheetNew
      53. SpreadsheetRead
      54. SpreadsheetReadBinary
      55. SpreadsheetRemoveSheet
      56. SpreadsheetSetActiveSheet
      57. SpreadsheetSetActiveSheetNumber
      58. SpreadsheetSetCellComment
      59. SpreadsheetSetCellFormula
      60. SpreadsheetSetCellValue
      61. SpreadsheetSetColumnWidth
      62. SpreadsheetSetFooter
      63. SpreadsheetSetHeader
      64. SpreadsheetSetRowHeight
      65. SpreadsheetShiftColumns
      66. SpreadsheetShiftRows
      67. SpreadsheetWrite
      68. Sqr
      69. StripCR
      70. StructAppend
      71. StructClear
      72. StructCopy
      73. StructCount
      74. StructDelete
      75. StructEach
      76. StructFilter
      77. StructFind
      78. StructFindKey
      79. StructFindValue
      80. StructGet
      81. StructGetMetadata
      82. StructInsert
      83. StructIsEmpty
      84. StructKeyArray
      85. StructKeyExists
      86. StructKeyList
      87. StructMap
      88. StructNew
      89. StructReduce
      90. StructSetMetadata
      91. StructSort
      92. StructToSorted
      93. StructUpdate
      94. StoreSetMetadata
      95. StoreGetACL
      96. StoreGetMetadata
      97. StoreAddACL
      98. StoreSetACL
    10. Functions-t-z
      1. Tan
      2. ThreadJoin
      3. ThreadTerminate
      4. Throw
      5. TimeFormat
      6. ToBase64
      7. ToBinary
      8. ToScript
      9. ToString
      10. Trace
      11. Transactionandconcurrency
      12. TransactionCommit
      13. TransactionRollback
      14. TransactionSetSavePoint
      15. Trim
      16. UCase
      17. URLDecode
      18. URLEncodedFormat
      19. URLSessionFormat
      20. Val
      21. ValueList
      22. VerifyClient
      23. Week
      24. Wrap
      25. WriteDump
      26. WriteLog
      27. WriteOutput
      28. WSGetAllChannels
      29. WSGetSubscribers
      30. WSPublish
      31. WSSendMessage
      32. XmlChildPos
      33. XmlElemNew
      34. XmlFormat
      35. XmlGetNodeType
      36. XmlNew
      37. XmlParse
      38. XmlSearch
      39. XmlTransform
      40. XmlValidate
      41. Year
      42. YesNoFormat
  3. ColdFusion Tags
    1. ColdFusion tag summary
    2. ColdFusion tags by category
      1. Application framework tags
        1. cfapplication
        2. cfassociate
        3. cferror
        4. cfimport
        5. cfinterface
        6. cflock
        7. cfscript
        8. cfthread
      2. Communications tags
        1. cfexchangecalendar
        2. cfexchangeconnection
        3. cfexchangecontact
        4. cfexchangefilter
        5. cfexchangemail
        6. cfexchangetask
        7. cffeed
        8. cfmail
        9. cfmailparam
        10. cfmailpart
        11. cfpopcfimap
      3. Database manipulation tags
        1. cfdbinfo
        2. cfinsert
        3. cfobjectcache
        4. cfprocparam
        5. cfprocresult
        6. cfquery
        7. cfqueryparam
        8. cfstoredproc
        9. cftransaction
        10. cfupdate
      4. Data output tags
        1. cfchart
        2. cfchartdata
        3. cfchartseries
        4. cfcol
        5. cfcontent
        6. cfdocument
        7. cfdocumentitem
        8. cfdocumentsection
        9. cfflush
        10. cfheader
        11. cflog
        12. cfoutput
        13. cfpresentation
        14. cfpresentationslide
        15. cfpresenter
        16. cfprocessingdirective
        17. cfprint
        18. cfreport
        19. cfreportparam
        20. cfsilent
        21. cftable
      5. Debugging tags
        1. cfdump
        2. cftimer
        3. cftrace
      6. Exception handling tags
        1. cfcatch
        2. cferror
        3. cffinally
        4. cfrethrow
        5. cfthrow
        6. cftry
      7. Extensibility tags
        1. cfchart
        2. cfchartdata
        3. cfchartseries
        4. cfcollection
        5. cfcomponent
        6. cfexecute
        7. cfftp
        8. function
        9. cfindex
        10. cfinterface
        11. cfinvoke
        12. cfinvokeargument
        13. cfobject
        14. cfproperty
        15. cfreport
        16. cfreportparam
        17. cfreturn
        18. cfsearch
        19. cfsharepoint
        20. cfspreadsheet
        21. cfwddx
        22. cfxml
      8. File management tags
        1. cfdirectory
        2. cffile
        3. cffileupload
        4. cfftp
        5. cfzip
        6. cfzipparam
      9. Flow-control tags
        1. cfabort
        2. cfbreak
        3. cfcase
        4. cfcontinue
        5. cfdefaultcase
        6. cfelse
        7. cfelseif
        8. cfexecute
        9. cfexit
        10. cfif
        11. cfinclude
        12. cflocation
        13. cfloop
        14. cfrethrow
        15. cfswitch
        16. cfthrow
        17. cftry
      10. Forms tags
        1. cfapplet
        2. cfcalendar
        3. cffileupload
        4. cfform
        5. cfformgroup
        6. cfformitem
        7. cfgrid
        8. cfgridcolumn
        9. cfgridrow
        10. cfgridupdate
        11. cfinput
        12. cfpdf
        13. cfpdfform
        14. cfpdfformparam
        15. cfpdfparam
        16. cfpdfsubform
        17. cfselect
        18. cfslider
        19. cftextarea
        20. cftree
        21. cftreeitem
      11. Internet Protocol tags
        1. cfajaximport
        2. cfajaxproxy
        3. cfftp
        4. cffeed
        5. cfimap
        6. cfhttp
        7. cfhttpparam
        8. cfldap
        9. cfmail
        10. cfmailparam
        11. cfmailpart
        12. cfpop
        13. cfsprydataset
      12. Page processing tags
        1. cfcache
        2. cfcontent
        3. cfflush
        4. cfheader
        5. cfhtmlhead
        6. cfinclude
        7. cfprocessingdirective
        8. cfsetting
        9. cfsilent
      13. Security tags
        1. cflogin
        2. cfloginuser
        3. cflogout
        4. cfNTauthenticate
      14. Variable manipulation tags
        1. cfcookie
        2. cfdump
        3. cfparam
        4. cfregistry
        5. cfsavecontent
        6. cfschedule
        7. cfset
        8. cfsetting
      15. Other tags
        1. cfimage
        2. cflog
        3. cfregistry
    3. Tags a-b
      1. cfabort
      2. cfajaximport
      3. cfajaxproxy
      4. cfapplet
      5. cfapplication
      6. cfargument
      7. cfassociate
      8. cfauthenticate
      9. cfbreak
    4. Tags c
      1. cfcache
      2. cfcalendar
      3. cfcase
      4. cfcatch
      5. cfchart
      6. cfchartdata
      7. cfchartseries
      8. cfclient
      9. cfclientsettings
      10. cfcol
      11. cfcollection
      12. cfcomponent
      13. cfcontent
      14. cfcontinue
      15. cfcookie
      16. Tags d-e
    5. Tags f
      1. cffeed
      2. cffile
      3. cffile action = "append"
      4. cffile action = "copy"
      5. cffile action = "delete"
      6. cffile action = "move"
      7. cffile action = "read"
      8. cffile action = "readBinary"
      9. cffile action = "rename"
      10. cffile action = "upload"
      11. cffile action = "uploadAll"
      12. cffile action = "write"
      13. cffileupload
      14. cffinally
      15. cfflush
      16. cfform
      17. cfformgroup
      18. cfformitem
      19. cfftp
      20. cfftp: Connection: file and directory operations
      21. cfftp: Opening and closing FTP server connections
      22. cfftp : Opening and closing secure FTP server connections
      23. cfftp action = "listDir"
      24. cffunction
    6. Tags g-h
      1. cfgraph
      2. cfgraphdata
      3. cfgrid
      4. cfgridcolumn
      5. cfgridrow
      6. cfgridupdate
      7. cfheader
      8. cfhtmlhead
      9. cfhtmltopdf
      10. cfhtmltopdfitem
      11. cfhttp
      12. cfhttpparam
    7. Tags i
      1. cfif
      2. cfimage
      3. cfimap
      4. cfimapfilter
      5. cfimpersonate
      6. cfimport
      7. cfinclude
      8. cfindex
      9. cfinput
      10. cfinsert
      11. cfinterface
      12. cfinvoke
      13. cfinvokeargument
    8. Tags j-l
      1. cfjava
      2. cflayout
      3. cflayoutarea
      4. cfldap
      5. cflocation
      6. cflock
      7. cflog
      8. cflogin
      9. cfloginuser
      10. cflogout
      11. cfloop
      12. cfloop : conditional loop
      13. cfloop : index loop
      14. cfloop : looping over a COM collection or structure
      15. cfloop : looping over a date or time range
      16. cfloop : looping over a list, a file, or an array
      17. cfloop : looping over a query
    9. Tags m-o
      1. cfmail
      2. cfmailparam
      3. cfmailpart
      4. cfmap
      5. cfmapitem
      6. cfmediaplayer
      7. cfmenu
      8. cfmenuitem
      9. cfmessagebox
      10. cfmodule
      11. cfNTauthenticate
      12. cfoauth
      13. cfobject
      14. cfobject: .NET object
      15. cfobject: COM object
      16. cfobject: component object
      17. cfobject: CORBA object
      18. cfobject: Java or EJB object
      19. cfobject: web service object
      20. cfobjectcache
      21. cfoutput
    10. Tags p-q
      1. cfparam
      2. cfpdf
      3. cfpdfform
      4. cfpdfformparam
      5. cfpdfparam
      6. cfpdfsubform
      7. cfpod
      8. cfpop
      9. cfpresentation
      10. cfpresentationslide
      11. cfpresenter
      12. cfprint
      13. cfprocessingdirective
      14. cfprocparam
      15. cfprocresult
      16. cfprogressbar
      17. cfproperty
      18. cfquery
      19. cfqueryparam
    11. Tags r-s
      1. cfregistry
      2. cfreport
      3. cfreportparam
      4. cfrethrow
      5. cfreturn
      6. cfsavecontent
      7. cfschedule
      8. cfscript
      9. cfsearch
      10. cfselect
      11. cfservlet
      12. cfservletparam
      13. cfset
      14. cfsetting
      15. cfsharepoint
      16. cfsilent
      17. cfslider
      18. cfspreadsheet
      19. cfsprydataset
      20. cfstoredproc
      21. cfswitch
    12. Tags t
      1. cftable
      2. cftextarea
      3. cftextinput
      4. cfthread
      5. cfthrow
      6. cftimer
      7. cftooltip
      8. cftrace
      9. cftransaction
      10. cftree
      11. cftreeitem
      12. cftry
    13. Tags u-z
      1. cfupdate
      2. cfwddx
      3. cfwebsocket
      4. cfwindow
      5. cfxml
      6. cfzip
      7. cfzipparam
  4. CFML Reference
    1. Reserved words and variables
      1. Reserved words and variables
      2. Reserved words
      3. Scope-specific built-in variables
      4. Custom tag variables
      5. ColdFusion tag-specific variables
      6. CGI environment (CGI Scope) variables
    2. Ajax JavaScript functions
      1. Ajax JavaScript functions
      2. Function summary Ajax
      3. ColdFusion.Ajax.submitForm
      4. ColdFusion.Autosuggest.getAutosuggestObject
      5. ColdFusion.Layout.enableSourceBind
      6. ColdFusion.MessageBox.getMessageBoxObject
      7. ColdFusion.ProgressBar.getProgressBarObject
      8. ColdFusion.MessageBox.isMessageBoxDefined
      9. JavaScriptFunctionsinColdFusion9Update1
    3. ColdFusion ActionScript functions
      1. ColdFusion ActionScript functions
      2. CF.http
      3. CF.query
    4. ColdFusion mobile functions
      1. ColdFusion Mobile Functions
      2. Accelerometer Functions
      3. Camera Functions
      4. Connection Functions
      5. Contact Functions
      6. Event Functions
      7. File System Functions
      8. Geolocation Functions
      9. Media and Capture Functions
      10. Notification Functions
      11. Splash Screen Functions
      12. Storage Functions
    5. Application.cfc reference
      1. Application.CFC reference
      2. Application variables
      3. Method summary
      4. onAbort
      5. onApplicationEnd
      6. onApplicationStart
      7. onMissingTemplate
      8. onCFCRequest
      9. onError
      10. onRequestEnd
      11. onRequest
      12. onRequestStart
      13. onServerStart
      14. onSessionEnd
      15. onSessionStart
    6. Script functions implemented as CFCs
      1. Script Functions Implemented as CFCs
      2. Accessing the functions
      3. Function summary
      4. ftp
      5. http
      6. mail
      7. pdf
      8. query
      9. Script functions implemented as CFCs in ColdFusion 9 Update 1
      10. storedproc
    7. ColdFusion Flash Form style reference
      1. Styles valid for all controls
      2. Styles for cfform
      3. Styles for cfformgroup with horizontal or vertical type attributes
      4. Styles for box-style cfformgroup elements
      5. Styles for cfformgroup with accordion type attribute
      6. Styles for cfformgroup with tabnavigator type attribute
      7. Styles for cfformitem with hrule or vrule type attributes
      8. Styles for cfinput with radio, checkbox, button, image, or submit type attributes
      9. Styles for cftextarea tag and cfinput with text, password, or hidden type attributes
      10. Styles for cfselect with size attribute value of 1
      11. Styles for cfselect with size attribute value greater than 1
      12. Styles for cfcalendar tag and cfinput with dateField type attribute
      13. Styles for the cfgrid tag
      14. Styles for the cftree tag
      15. ColdFusion Flash Form Style Reference
    8. ColdFusion event gateway reference
      1. ColdFusion Event Gateway reference
      2. addEvent
      3. CFEvent
      4. CFEventclass
      5. Constructor
      6. Gateway development interfaces and classes
      7. getStatus
      8. setCFCPath
      9. setCFCMethod
      10. getOriginatorID
      11. getLogger
      12. getBuddyList
      13. getBuddyInfo
      14. IM gateway message sending commands
      15. IM Gateway GatewayHelper class methods
      16. onIncomingMessage
      17. onIMServerMessage
      18. onBuddyStatus
      19. onAddBuddyResponse
      20. onAddBuddyRequest
      21. IM Gateway CFC incoming message methods
      22. IM gateway methods and commands
      23. CFML CFEvent structure
      24. warn
      25. info
      26. setOriginatorID
      27. data command
      28. submit Multi command
      29. submit command
      30. setGatewayType
      31. setGatewayID
      32. setData
      33. setCFCListeners
      34. outgoingMessage
      35. getStatusTimeStamp
      36. numberOfMessagesReceived
      37. numberOfMessagesSent
      38. removeBuddy
      39. removeDeny
      40. removePermit
      41. setNickName
      42. setPermitMode
      43. setStatus
      44. SMS Gateway CFEvent structure and commands
      45. SMS Gateway incoming message CFEvent structure
      46. getStatusAsString
      47. getProtocolName
      48. getPermitMode
      49. getPermitList
      50. getNickName
      51. getName
      52. getDenyList
      53. getCustomAwayMessage
      54. getQueueSize
      55. getMaxQueueSize
      56. getHelper
      57. getGatewayType
      58. getGatewayServices
      59. getGatewayID_1
      60. getGatewayID
      61. getData
      62. getCFCTimeout
      63. setCFCTimeout
      64. getCFCPath
      65. getCFCMethod
      66. GatewayServices class
      67. Gateway interface
      68. GatewayHelper interface
      69. addPermit
      70. addDeny
      71. addBuddy
      72. error
      73. debug
      74. Logger class
      75. stop
      76. start
      77. CFML event gateway SendGatewayMessage data parameter
      78. restart
      79. fatal
      80. SMS gateway message sending commands
    9. ColdFusion C++ CFX Reference
      1. C++ class overview
      2. Deprecated class methods
      3. CCFXException class
      4. CCFXQuery class
      5. CCFXRequest class
      6. CCFXStringSet class
      7. ColdFusion C++ CFX Reference
    10. ColdFusion Java CFX reference
      1. ColdFusion Java CFX reference
      2. Class libraries overview
      3. Custom tag interface
      4. Query interface
      5. Request interface
      6. Response interface
      7. Debugging classes reference
    11. WDDX JavaScript Objects
      1. WDDX JavaScript objects
      2. JavaScript object overview
      3. WddxRecordset object
      4. WddxSerializer object
  5. Cloud services
    1. ColdFusion and GCP Storage
    2. ColdFusion and GCP Firestore
    3. ColdFusion and GCP PubSub
    4. ColdFusion and Amazon S3
    5. ColdFusion and DynamoDB
    6. ColdFusion and Amazon SQS
    7. ColdFusion and Amazon SNS
    8. ColdFusion and MongoDB
    9. ColdFusion and Azure Blob
    10. ColdFusion and Azure Service Bus
    11. Multi-cloud storage services
    12. Multi-cloud RDS databases
    13. ColdFusion and Azure Cosmos DB

 

Introduction

Amazon S3 or Amazon Simple Storage Service is a service offered by Amazon Web Services (AWS) that provides object storage through a web service interface. Amazon S3 can be employed to store any type of object which allows for uses like storage for Internet applications, backup and recovery, disaster recovery, data archives, data lakes for analytics, and hybrid cloud storage.

Amazon S3 stores data as objects within buckets. An object consists of a file and optionally any metadata that describes that file.

To store an object in Amazon S3, you upload the file you want to store to a bucket. When you upload a file, you can set permissions on the object as well as any metadata.

Buckets are the roots for objects. You can have one or more buckets. For each bucket, you can control access to it (who can create, delete, and list objects in the bucket), view access logs for it and its objects, and choose the geographical region where Amazon S3 will store the bucket and its contents.

For more information, see Amazon S3 storage.

ColdFusion and S3

Amazon S3 storage service is used to store and retrieve any amount of data, at any time, from anywhere on the web. ColdFusion (2016 release) and ColdFusion (2018 release) supported this feature using tags and functions that take file or directory as input or output. In ColdFusion (2021 release), we’ve extended the feature further to support Multi-cloud service.

You can use S3 storage in the following scenarios:

  • Create storage in S3.
  • Perform root operations like create, upload, list and delete.
  • Set policies to the bucket.
  • Upload files in bulk.
  • Copy files from one bucket to another.
  • Create different versions of the file in the storage.
  • Set lifecycles rules to the objects.
  • Add tags to the objects.
  • Secure your S3 space.
  • Upload or download files in parallel.

Get started

Install awss3 package

Adobe ColdFusion (2021 release) is modularized, if you are only using the ZIP installer. By default, the module for AWS S3 is not installed. The first step is to install the S3 package in ColdFusion.

Note: If you are using the GUI installer, The package for S3 is called awss3.

The package for SNS is called awss3.

To install the package awss3, use the Package Manager page in the ColdFusion Administrator, or follow the steps below:

  1. Navigate to <CF_HOME>/cfusion/bin.

  2. Enter the command:

    • Windows: cfpm.bat
    • Linux: cfpm.sh
  3. Enter the command, install awss3.

    Wait for the AWS S3 package to get installed.

For more information, see ColdFusion Package Manager.

Get credentials to access AWS S3

When you interact with AWS, you specify your AWS security credentials to verify your credentials and check whether you have permission to access the resources that you are requesting.

AWS uses the security credentials to authenticate and authorize your requests.

You must get the AWS Access Key ID and the AWS Secret Access Key. For more information, see Access Keys.

Add cloud service credentials and configuration

In ColdFusion (2021 release), there is a method getCloudService() that gives you a handle to create objects for accessing various cloud services.

The syntax of the service handle is as follows:

service=getCloudService(cloudCred,cloudConfig), where:

  • cloudCred: Defines the credentials for the cloud service. It could either be a struct or a string (also known as credential alias).
  • cloudConfig: Defines the cloud service configuration details. It could either be a struct or a string (also known as config alias).

After you've acquired the AWS credentials, you must declare these credentials in one of the following ways. Only then you can use these credentials to create an S3 object, after which you can use the object to make calls to the various S3 methods.

Note:

You must store the result of getCloudService in a shared scope (for example, application scope) and re-use that object.

ColdFusion Administrator

Set credentials

In the ColdFusion Administrator, click Data & Services > Cloud Credentials

An alias is a named representation of a cloud service and its configuration details. You can set the config alias through ColdFusion Administrator.

Add cloud credentials
Add cloud credentials

After entering the details, click Add Credential.

Set configuration options

In the ColdFusion Administrator, click Data & Services > Cloud Configuration

Enter the following details, like configuration Alias, Vendor, and the name of the service.

Add cloud configuration options
Add cloud configuration options

After adding the configuration options, you may need to add a few more options. You can do so in the next screen. The following are a few options that you may need to add:

  • Request config
  • Client config
  • Proxy settings
  • Retry policy
  • Retry conditions

For more information, see Cloud configuration options.

Create the object

Once you've created the aliases for S3 credential and configuration options, you can create the object by using the getCloudService API, and include the following in your CFM. 

application.s3Object= getCloudService("s3Cred", "s3Conf")

Application.cfc

You can specify the S3 credentials and configuration options in Application.cfc. For example,

component 
{ 
    this.name="S3_app"; 
    void function onApplicationStart(){ 
        application.awsCred  = { 
                                "alias" : "aws_std_queue", 
                                "vendorName" : "AWS", 
                                "region" : "us-east-2", 
                                "secretAccessKey" : "xxxxxxxxxxxxxxxxx", 
                                "accessKeyId" : "xxxxxxxxxxxxxxxx" 
                             } 
              
        application.s3Conf  = { 
                                "serviceName" : "S3" 
                             } 
  
         
    } 
}

Create the object

application.s3Object = getCloudService(application.awsCred, application.s3Conf) 

On CFM page

On a CFM page, you can specify the S3 credentials and configuration options in one of the four methods, specified below:

Credential alias and configuration alias

After you've created the aliases for S3 credential and configuration options, you can use these aliases in the getCloudService
handle as shown below:

<cfscript> 
  // define the credential and the configuration aliases in the ColdFusion Admin 
  application.s3=getCloudService("awsCred","s3Conf") 
  // code below. 
  ........... 
</cfscript>

Credential Alias and Struct for configuration options

<cfscript> 
    // Using credential alias and struct for service config 
    s3Conf = { 
            "alias":"s3Conf", 
            "serviceName" : "S3", 
            "clientOverrideConfig":{ 
                "retryPolicy":{ 
                  "numRetries":4 
                } 
            }, 
            "httpClientConfig":{ 
                "maxConnections":50 
            } 
   
    } 
    application.s3= getCloudService("s3Cred", s3Conf) 
   
    // code below 
    ..................... 
</cfscript>

Configuration alias and struct for credentials

<cfscript> 
    // Using config alias and struct for service credentials 
    // s3 credentials 
    s3Creds={ 
      "vendorName":"AWS", 
      "alias": "s3Cred", 
      "region":"us-east-2", 
      "accessKeyId": "access key", 
      "secretAccessKey": "secret access" 
    } 
    application.s3= getCloudService(s3Creds, "s3Conf") 
    // code below 
    ..................................... 
</cfscript>

Structs for both credential and configuration options

<cfscript> 
  // Using Structs for both cloud credential and config 
  s3Cred={ 
    "vendorName":"AWS", 
    "alias": "s3_cred_alias", 
    "region":"us-east-2", 
    "accessKeyId": "access key", 
    "secretAccessKey": "secret access key" 
  } 
   
  s3Conf = { 
          "alias":"s3_conf_alias", 
          "serviceName" : "S3", 
          "clientOverrideConfig":{ 
              "retryPolicy":{ 
                "numRetries":4 
              } 
          }, 
          "httpClientConfig":{ 
              "maxConnections":50 
          } 
   
  } 
  application.s3 = getCloudService(s3Cred, s3Conf ) 
   
  // code below 
  ................................................................... 
</cfscript>

Admin API

You can also add SQS credentials and configuration options by using the Admin APIs. The methods to add credentials and configuration are available in cloud.cfc.

The examples below demonstrate the usage of the methods addCredential(struct credential) and addServiceConfig(struct config).

Add credentials

<cfscript> 
  // Create an object of administrator component and call the login method 
  adminObj = createObject("component","cfide.adminapi.administrator") 
  adminObj.login("admin") 
   
  // Create an object of cloud component 
  cloudObj = createObject("component","cfide.adminapi.cloud") 
   
  // define credentials struct 
  credentialStruct={ 
    "alias" : "CredS3", 
    "vendorName" : "AWS", 
    "region" : "us-east-2", 
    "secretAccessKey" : "secret access key", 
    "accessKeyId" : "access key" 
  } 
   
  // add credential credentialStruct 
  try{ 
    cloudObj.addCredential(credentialStruct) 
    writeOutput("Credentials added successfully") 
  } 
  catch(any e){ 
      writeDump(e) 
  } 
</cfscript>

Add configuration

<cfscript> 
  // Create an object of administrator component and call the login method 
  adminObj = createObject("component","cfide.adminapi.administrator") 
  adminObj.login("admin") 
   
  // Create an object of cloud component 
  cloudObj = createObject("component","cfide.adminapi.cloud") 
   
  // define configuration struct 
  configStruct={ 
      "alias":"ConfS3", 
      "serviceName":"S3", 
      "clientOverrideConfig":{ 
          "retryPolicy":{ 
              "numRetries":4 
          } 
      }, 
      "httpClientConfig":{ 
          "maxConnections":50 
      } 
  } 
   
  // add config configStruct 
  try{ 
    cloudObj.addServiceConfig(configStruct) 
    writeOutput("Configuration service added successfully") 
  } 
  catch(any e){ 
    writeDump(e) 
  } 
</cfscript>

CFSetup

You can also set up S3 credential and configuration via the CFSetup configuration utility.

Add cloud credential

  • add cloudcredential credentialAlias=s3cred accesskeyid=<access> secretaccesskey=<secret> region=ap-southeast-1 vendorname=AWS

Set credential

  • set cloudcredential s3cred secretaccesskey=awssecret

Add cloud configuration

  • add cloudconfiguration serviceName=S3 alias=s3Config

Set configuration

  • set cloudconfiguration conf1 alias=conf2

Create root

Get the root object. If the root doesn't exist, the root gets created.

  • Amazon S3- Yes
  • Azure- Yes
  • Multi-cloud- Yes

Syntax

root(bucketname, createIfNotExists)

Parameters

Parameter

Description

bucketName

The name of the bucket to be created.

createIfNotExists

True or False. If the bucket doesn't exist, it gets created.

Example

<cfscript> 
  storageService = getCloudService(application.awsCred,application.s3Conf) 
  try{ 
    storageService.root("bucket.001","true") 
    writeOutput("Bucket created successfully") 
  } 
  catch(any e){ 
    writeDump(e) 
  } 
</cfscript>

Create root- additional parameters

Get the root object with additional parameters.

  • Amazon S3- Yes
  • Azure- Yes
  • Multi-cloud- Yes

Syntax

createRoot(requestParameters)

Parameters

Parameter

Description

bucketName

The name of the bucket to be created.

objectLockEnabledForBucket

Yes or No. Identifies if object lock is enabled for the bucket. For more information, see Object locks.

acl

Amazon S3 access control lists (ACLs) enable you to manage access to buckets and objects.

Valid values are:

  • PRIVATE: Only owner of the bucket has full control of the bucket and its objects.
  • PUBLIC_READ: Owner of the bucket has full control. Members of AllUsers group have READ rights to the bucket and its objects.
  • PUBLIC_READ_WRITE: Owner gets FULL_CONTROL. The AllUsers group gets READ and WRITE access.
  • AUTHENTICATED_READ: Owner gets FULL_CONTROL. The AuthenticatedUsers group gets READ access.

For more information, see ACLs in AWS.

grant permission variables

Permissions that Amazon S3 supports in an ACL.

Valid values are:

  • grantFullControl: Allows the grantee full control of the bucket.
  • grantRead: Allows the grantee to view the objects in the bucket.
  • grantWrite: Allows the grantee to create, overwrite, and delete any object in the bucket.
  • grantWriteACP: Allows the grantee to write the ACL for the bucket.

For more information, see Permissions.

Example

<cfscript> 
  storageService = getCloudService(application.awsCred,application.s3Conf) 
   
  createBucketRequest = { 
      "acl":"PRIVATE", 
       "bucket" : "bucket.002", 
       "objectLockEnabledForBucket" : true 
  } 
  //  create a root 
  myobj=storageService.createRoot(createBucketRequest) 
  writeDump(myobj) 
</cfscript> 

Create bucket

To upload your data to Amazon S3, you must get the bucket object in one of the AWS Regions. You can then upload any number of objects to the bucket.

For more information, see S3 buckets.

Syntax

bucket(bucketName,createIfNotExists)

Parameters

Parameter

Description

bucketName

The name of the bucket to be created.

createIfNotExists

True or False. If the bucket doesn't exist, it gets created.

Example

<cfscript> 
  storageService = getCloudService(application.awsCred,application.s3Conf) 
  try{ 
    storageService.bucket("bucket.002","true") 
    writeOutput("Bucket created successfully") 
  } 
  catch(any e){ 
    writeDump(e) 
  } 
</cfscript>

Create bucket- additional parameters

Create a bucket in S3 with additional parameters.

Syntax

createBucket(parameterStruct)

Parameters

Parameter

Description

bucketName

The name of the bucket to be created.

objectLockEnabledForBucket

Yes or No. Identifies if object lock is enabled for the bucket. For more information, see Object locks.

acl

Amazon S3 access control lists (ACLs) enable you to manage access to buckets and objects.

Valid values are:

  • PRIVATE: Only owner of the bucket has full control of the bucket and its objects.
  • PUBLIC_READ: Owner of the bucket has full control. Members of AllUsers group have READ rights to the bucket and its objects.
  • PUBLIC_READ_WRITE: Owner gets FULL_CONTROL. The AllUsers group gets READ and WRITE access.
  • AUTHENTICATED_READ: Owner gets FULL_CONTROL. The AuthenticatedUsers group gets READ access.

For more information, see ACLs in AWS.

grant permission variables

Permissions that Amazon S3 supports in an ACL.

Valid values are:

  • grantFullControl: Allows the grantee full control of the bucket.
  • grantRead: Allows the grantee to view the objects in the bucket.
  • grantWrite: Allows the grantee to create, overwrite, and delete any object in the bucket.
  • grantWriteACP: Allows the grantee to write the ACL for the bucket.

For more information, see Permissions.

Example

<cfscript> 
  storageService = getCloudService(application.awsCred,application.s3Conf) 
  // bucketList=storageService.listAll() // lists all buckets 
  // writeDump(bucketList) 
  // abort; 
  createBucketRequest = { 
       "acl":"PRIVATE", 
       "bucket" : "bucket.three.demo", 
       "objectLockEnabledForBucket" : true 
  } 
  //  create a bucket 
  try{ 
    myobj=storageService.createBucket(createBucketRequest) 
    writeOutput("Bucket created successfully") 
    writeDump(myobj) 
  } 
  catch (any e){ 
    writeOutput("Failed to create the bucket") 
    writeDump(e) 
  } 
</cfscript> 

Delete a bucket

You can delete an empty bucket, and when you're using the AWS Management Console, you can delete a bucket that contains objects. If you delete a bucket that contains objects, all the objects in the bucket are permanently deleted.

For more information, see DeleteObjects.

  • Amazon S3- Yes
  • Azure- Yes
  • Multi-cloud- Yes

Syntax

delete(parameterStruct)
delete(bucketName)

Parameters

Parameter

Description

bucketName

The name of the bucket to delete.

forcedDelete

True or False. Force deletes a bucket that has obejcts in it.

Example

<cfscript> 
  storageService = getCloudService(application.awsCred,application.s3Conf) 
  createBucketRequest = { 
    "acl":"PRIVATE", 
    "bucket" : "bucket.name", 
    "objectLockEnabledForBucket" : true 
  } 
  storageService.createBucket(createBucketRequest) 
  // delete the bucket 
  deleteBucketRequest = { 
      "bucket" : "bucket.name", 
      "forcedDelete" : "true" // default: false 
  } 
  try{ 
    myobj=storageService.delete(deleteBucketRequest) 
    writeOutput("Bucket deleted successfully") 
    writeDump(myobj) 
  } 
  catch (any e){ 
    writeOutput("Unable to delete the bucket") 
    writeDump(e) 
  } 
</cfscript> 

Delete an object

Here's how you'll delete an object in a bucket.

<cfscript> 
  storageService = getCloudService(application.awsCred,application.s3Conf) 
  rootObj=storageService.bucket("bucket001","true") 
  try{ 
    rootObj.delete("key") 
    writeOutput("Object created successfully") 
  } 
  catch(any e){ 
    writeDump(e) 
  } 
</cfscript>

Delete the key from a bucket

<cfscript> 
  storageService = getCloudService(application.awsCred,application.s3Conf) 
  //writeOutput(ExpandPath('./')) 
  // create a bucket 
  createBucketRequest = { 
    "acl":"PRIVATE", 
    "bucket" : "bucket.name", 
    "objectLockEnabledForBucket" : true 
  } 
  bucketObj=storageService.createBucket(createBucketRequest) 
  // upload an object 
  uploadStruct = { 
        "srcFile" : "#ExpandPath('./')#/file.txt", 
        "key" : "key12", 
        "metadata":{ 
          "place":"London", 
          "deployment":"Testing" 
        } 
  } 
  try{ 
    deleteResponse=bucketObj.delete("key12")
    writeOutput("Object deleted successfully") 
    writeDump(deleteResponse) 
  } 
  catch (any e){ 
    writeOutput("Could not delete the object") 
    writeDump(e) 
  } 
</cfscript>

Upload a file

You can upload a file to a bucket. In the function uploadFile, as argument, pass a struct with the following values:

For more information, see the official docs.

Syntax

uploadFile(parameterStruct)

Parameters

Parameter Description Required
srcFile
The path of the file that you want to upload in the bucket. Yes
key
Unique identifier of the object. Yes
acl

The ACL to apply to the object. For more information, see Canned ACL.The valid values are:

  • PRIVATE
  • PUBLIC_READ
  • PUBLIC_READ_WRITE
  • AUTHENTICATED_READ
  • AWS_EXEC_READ
  • BUCKET_OWNER_READ
  • BUCKET_OWNER_FULL_CONTROL
No
cacheControl
Specify the caching behavior as defined here. No
contentDisposition
Specify the content format of the object as defined here. No
contentEncoding
Specify the type of encoding on the object as defined here. No
contentLanguage
The language of the object that you want to upload. No
contentLength
The size of the object in bytes. No
validateContentMD5
True or False. The base64-encoded 128-bit MD5 digest of the message (without the headers).
No
contentType
The format of the content as defined here. No
expires
The date and time when the object cannot be cached any longer.
No
grantFullControl
Gives the grantee READ, READ_ACP, and WRITE_ACP permissions on the object.
No
grantRead
Allows grantee to only read the object data.
No
grantWrite
Allows grantee to write to the object data.
No
grantReadACP
Allows grantee to read the object ACL.
No
grantWriteACP
Allows grantee to write the ACL for the object.
No
metadata
The object metadata to use. No
serverSideEncryption
The server-side encryption algorithm to be used.
No
storageClass

Valid values are:

  • STANDARD
  • REDUCED_REDUNDANCY
  • STANDARD_IA
  • ONEZONE_IA
  • INTELLIGENT_TIERING
  • GLACIER
  • DEEP_ARCHIVE

For more information, see S3 storage class.

No
websiteRedirectLocation
If the bucket is configured as a website, specify the redirect request to another object in the same bucket or to an external URL.
No
sseCustomerAlgorithm
Specifies the algorithm to use to when encrypting the object.
No
sseCustomerKey
Specifies the customer-provided encryption key for S3 to use in encrypting data. 
No
ssekmsKeyId
Specifies the ID of the AWS Key Management Service (AWS KMS).
No
ssekmsEncryptionContext
Specifies the AWS KMS Encryption Context to use for object encryption. 
No
requestPayer
Confirms that the requester knows that they will be charged for the request.
No
tagging
The tag-set for the object. Must be a struct of key-value pairs.
No
objectLockMode

The Object locking mode that you want to apply to this object. Valid values are:

  • GOVERNANCE
  • COMPLIANCE
No
objectLockRetainUntilDate
The date and time when you want this object's Object Lock to expire.
No
objectLockLegalHoldStatus

Indicates whether the specified object has a Legal Hold in place.. Valid values are:

  • ON
  • OFF
No

Example

<cfscript> 
  storageService = getCloudService(application.awsCred,application.s3Conf) 
  //writeOutput(ExpandPath('./')) 
  // create a bucket 
  createBucketRequest = { 
    "acl":"PRIVATE", 
    "bucket" : "bucket.name", 
    "objectLockEnabledForBucket" : true 
  } 
  bucketObj=storageService.createBucket(createBucketRequest) 
  // upload an object 
  uploadStruct = { 
        "srcFile" : "#ExpandPath('./')#/file.txt", 
        "key" : "key12", 
        "metadata":{ 
          "place":"London", 
          "deployment":"Testing" 
        } 
  } 
  try{ 
    uploadResponse=bucketObj.uploadFile(uploadStruct) 
    writeOutput("Object uploaded successfully") 
    writeDump(uploadResponse) 
  } 
  catch (any e){ 
    writeOutput("Could not upload the object") 
    writeDump(e) 
  } 
</cfscript>

Download a file

You can download a file from an S3 bucket. To download a file, use the function downloadToFile. As an argument, pass a struct with the following values:

For more information, see the official docs.

Syntax

downloadToFile(parameterStruct)

Parameters

Parameter Description Required
destinationFile
The path of the file that that contains the object, which you want to download. Yes
key
Unique identifier of the object. Yes
cacheControl
Set the cache control header of the object, No
contentDisposition
Set the Content-Disposition header of the response.
No
contentEncoding
Set the Content-Encoding header of the response.
No
contentLanguage
Set the Content-Language header of the response.
No
contentType
Set the Content-Type header of the response.
No
expires
Sets the Response header of the response.
No
versionId
Refer to a specific version of the object. No
sseCustomerAlgorithm
Specify the algorithm to use to when encrypting the object.
No
sseCustomerKey
Specify the customer-provided encryption key for S3 to use in encrypting data.
No
requestPayer
Confirms that the requester knows that they will be charged for the request.
No

Example

<cfscript> 
  storageService = getCloudService(application.awsCred,application.s3Conf) 
  // create a bucket 
  createBucketRequest = { 
      "acl":"PRIVATE", 
      "bucket" : "bucket.demo.four", 
      "objectLockEnabledForBucket" : true 
  } 
  bucketObj=storageService.createBucket(createBucketRequest) 
  // upload an object 
  uploadStruct = { 
        "srcFile" : "#ExpandPath('./')#/file.txt", 
        "key" : "key22", 
        "metadata":{ 
          "filename":"file.txt", 
          "place":"bangalore", 
          "category":"finance" 
        } 
  } 
  bucketObj.uploadFile(uploadStruct) 
  // download the file 
  downloadStruct = { 
    "destinationFile" : "file.txt", 
    "key" : "key22" 
  } 
  try{ 
    downloadResponse=bucketObj.downloadToFile(downloadStruct) 
    writeOutput("Object downloaded successfully") 
    writeDump(downloadResponse) 
  } 
  catch (any e){ 
    writeOutput("Failed to download object") 
    writeDump(e) 
  } 
</cfscript>

List all objects

You can get a list of buckets in storage account. You can also retrieve a list of objects inside the bucket.

  • Amazon S3- Yes
  • Azure- Yes
  • Multi-cloud- Yes

Syntax

listAll(parameterStruct)
listAll()

Parameters

Parameter

Description

delimiter

Character to group keys.

encodingType

Encode the object keys in the response and specifies the encoding method to use.

marker

Key to start with when listing objects in a bucket.

maxKeys

The maximum number of keys returned in the response. 

prefix

Limits the response to keys that begin with the specified prefix.

requestpayer

Confirms that the requester knows that he/she will be charged for the request. Valid value is REQUESTER.

For more information, see request parameters.

Example

<cfscript> 
  storageService = getCloudService(application.awsCred,application.s3Conf) 
  // lists all buckets 
  bucketList=storageService.listAll() 
  writeOutput("List of buckets") 
  writeDump(bucketList) 
</cfscript>

Copy an object

You can copy an object from one bucket to another. All copy requests must be authenticated. Additionally, you must have read access to the source object and write access to the destination bucket. 

For more information, see Copy objects.

Syntax

copy(parameterStruct)

Parameters

Parameter

Description

Required

sourceBucket

The bucket from where you want to copy the object.

Yes

sourceKey

The key associated with the object.

Yes

sourceVersionId

The version id that was associated with the object.

No

key

The destination key of the object.

Yes

storageClass

For more information, see S3 storage class.. Valid value is: GLACIAR.

No

Example

<cfscript> 
  storageService = getCloudService(application.awsCred,application.s3Conf) 
  // create two buckets 
  createBucketRequest1 = { 
      "acl":"PRIVATE", 
       "bucket" : "cf.source.bucket.1", 
       "objectLockEnabledForBucket" : true 
  } 
  createBucketRequest2 = { 
      "acl":"PRIVATE", 
       "bucket" : "cf.dest.bucket.1", 
       "objectLockEnabledForBucket" : true 
  } 
  // source bucket 
  source_obj=storageService.createBucket(createBucketRequest1) 
  // destination bucket 
  dest_object=storageService.createBucket(createBucketRequest2) 
  // upload file struct 
  uploadStruct = { 
        "srcFile" : "#ExpandPath('./')#/file.txt", 
        "key" : "key12" 
    } 
  // upload file to source bucket 
  uploadResponse=source_obj.uploadFile(uploadStruct) 
  // copy file struct 
  copyRequest = { 
        "sourceBucket": "cf.source.bucket.1", 
        "sourceKey" : "key12", 
        "key" : "destKey" 
  } 
  copyResponse=dest_object.copy(copyRequest); 
  objList=dest_object.listAll() 
  writeDump(objList) 
 
</cfscript>

Apply policy to a bucket

Applies an Amazon S3 bucket policy to an Amazon S3 bucket.

For more information, see Put bucket policy.

Syntax

putPolicy(parameterStruct)

Parameters

Parameter

Description

Required

confirmRemoveSelfBucketAccess

True or False. Set this parameter to true to confirm that you want to remove your permissions to change this bucket policy in the future.

No

policy

The policy to be enforced for the bucket. For more information, see S3 policies.

No

Example

<cfscript> 
    storageService = getCloudService(application.awsCred,application.s3Conf) 
    bucketList=storageService.listAll() 
    //writeDump(bucketList) 
    rootObj=storageService.bucket("bucket.policy","true") 
    
    policy = {    
        "Id": "Policy1571390473326",  
        "Version": "2012-10-17", 
        "Statement": [ 
            { 
            "Sid": "Stmt1574139965216", 
            "Action": [ 
              "s3:GetBucketAcl" 
            ], 
            "Effect": "Allow", 
            "Resource": "bucket.policy", 
            "Principal": "*" 
          }  
         ] 
      }     
       
      policyRequest = { 
          "policy" : policy 
      } 
      
      rootObj.putPolicy(policyRequest); 
      writedump(rootObj.getPolicies()) 
</cfscript>

Delete a policy

Delete a policy that was applied on a bucket.

For more information, see Delete bucket policy.

Syntax

deletePolicies()

Example

<cfscript> 
    storageService = getCloudService(application.awsCred,application.s3Conf) 
    bucketList=storageService.listAll() 
    //writeDump(bucketList) 
    rootObj=storageService.bucket("bucket.policy","true")   
        
    policy = {    
        "Id": "Policy1571390473326",  
        "Version": "2012-10-17", 
        "Statement": [ 
            { 
            "Sid": "Stmt1574139965216", 
            "Action": [ 
              "s3:GetBucketAcl" 
            ], 
            "Effect": "Allow", 
            "Resource": "bucket.policy", 
            "Principal": "*" 
          }  
         ] 
      }     
       
      policyRequest = { 
          "policy" : policy 
      } 
      
      rootObj.putPolicy(policyRequest); 
      writedump(rootObj.getPolicies()) 
      // delete policy 
      deletePolicyResponse=rootObj.deletePolicies() 
      writeDump(deletePolicyResponse) 
</cfscript>

Retrieve a policy

Return the policy of a specified bucket.

For more information, see Get bucket policy.

Syntax

getPolicies()

Example

<cfscript> 
    storageService = getCloudService(application.awsCred,application.s3Conf) 
    bucketList=storageService.listAll() 
    //writeDump(bucketList) 
    rootObj=storageService.bucket("bucket.policy","true") 
    
   policy = {    
        "Id": "Policy1571390473326",  
        "Version": "2012-10-17", 
        "Statement": [ 
            { 
            "Sid": "Stmt1574139965216", 
            "Action": [ 
              "s3:GetBucketAcl" 
            ], 
            "Effect": "Allow", 
            "Resource": "bucket.policy", 
            "Principal": "*" 
          }  
         ] 
      }     
       
      policyRequest = { 
          "policy" : policy 
      } 
      
      rootObj.putPolicy(policyRequest); 
      writedump(rootObj.getPolicies()) 
      // delete policy 
      deletePolicyResponse=rootObj.deletePolicies() 
      writeDump(deletePolicyResponse) 
</cfscript>

Versioning

Versioning is a means of keeping multiple variants of an object in the same bucket. You can use versioning to preserve, retrieve, and restore every version of every object stored in your Amazon S3 bucket. With versioning, you can easily recover from both unintended user actions and application failures.

In one bucket, for example, you can have two objects with the same key, but different version IDs.

AWS S3 Version: uploading objects in non-versioned and versioning-enabled buckets are the same, although, in the case of versioning-enabled buckets, Amazon S3 assigns a version number. Otherwise, the version number is null. Enabling and suspending versioning is done at the bucket level.

Enable versioning

Set the versioning state of an existing bucket. To set the versioning state, you must be the bucket owner.

You can set the versioning state with one of the following values:

  • Enabled
  • Suspended

For more information, see Enable versioning.

Syntax

enableVersioning(parameterStruct)

Parameters

Parameter

Description

Required

mfa

The combination of the authentication device's serial number, a space, and the value that is displayed on your authentication device.

The format of the mfa is:

"mfa":"arn:aws:iam::0123456789:mfa/username"

No

mfaDelete

Specifies whether MFA delete is enabled in the bucket versioning configuration. Valid values are:

  • Enabled
  • Disabled

No

Example

<cfscript> 
  storageService = getCloudService(application.awsCred,application.s3Conf) 
  // create a bucket 
  createBucketRequest = { 
     "acl":"PRIVATE", 
     "bucket" : "bucket.demo.getstatus", 
     "objectLockEnabledForBucket" : true 
  } 
  //  create a bucket 
  bucketObj=storageService.createBucket(createBucketRequest) 
  // enable versioning 
  bucketObj.enableVersioning() 
  // get version status 
  versionStatus=bucketObj.getVersioningStatus() 
  writeDump(versionStatus) 
</cfscript> 

Get version status

Get the versioning state of a bucket.

Syntax

getVersioningStatus()

Example

<cfscript> 
  storageService = getCloudService(application.awsCred,application.s3Conf) 
  // create a bucket 
  createBucketRequest = { 
     "acl":"PRIVATE", 
     "bucket" : "bucket.demo.getstatus", 
     "objectLockEnabledForBucket" : true 
  } 
  //  create a bucket 
  bucketObj=storageService.createBucket(createBucketRequest) 
  // enable versioning 
  bucketObj.enableVersioning() 
  // get version status 
  versionStatus=bucketObj.getVersioningStatus() 
  writeDump(versionStatus) 
</cfscript>

List all versions

Return metadata about all versions of the objects in a bucket.

For more information, see List object versions.

Syntax

listAllVersions(parameterStruct)

Parameters

Parameter

Description

Required

delimiter

Character to group keys.

No

encodingType

Requests Amazon S3 to encode the object keys in the response and specifies the encoding method to use. 

No

marker

The object version you want to start listing from.

No

maxKeys

Sets the maximum number of keys returned in the response.

No

prefix

Select only those keys that begin with the specified prefix. 

No

keyMarker

The key to start with when listing objects in a bucket.

No

Example

<cfscript> 
  storageService = getCloudService(application.awsCred,application.s3Conf) 
  // create a bucket 
  createBucketRequest = { 
     "acl":"PRIVATE", 
     "bucket" : "bucket.demo.listversions", 
     "objectLockEnabledForBucket" : true 
  } 
  //  create a bucket 
  myobj=storageService.createBucket(createBucketRequest) 
  // define file upload structs 
  uploadStruct1 = { 
          "srcFile" : "#ExpandPath('./')#/file1.txt", 
          "key" : "key1" 
  } 
 
  uploadStruct2 = { 
        "srcFile" : "#ExpandPath('./')#/file2.txt", 
        "key" : "key122" 
  } 
 
  uploadStruct3 = { 
        "srcFile" : "#ExpandPath('./')#/file3.txt", 
        "key" : "key123" 
  } 
 
  uploadStruct4 = { 
          "srcFile" : "#ExpandPath('./')#/file1.txt", 
          "key" : "key124" 
  } 
   
  uploadResponse1=myobj.uploadFile(uploadStruct1); 
  uploadResponse2=myobj.uploadFile(uploadStruct2); 
  uploadResponse3=myobj.uploadFile(uploadStruct3); 
  uploadResponse4=myobj.uploadFile(uploadStruct4); 
   
  listAllVersionsRequest={ 
    "prefix" : "key12" 
  } 
 
   
  // list all versions 
  listVersion=myobj.listAllVersions(listAllVersionsRequest) 
  writeDump(listVersion) 
</cfscript>

Suspend versioning

Disable versioning for the objects in the bucket.

For more information, see Suspend versioning.

Syntax

suspendVersioning(parameterStruct)

Parameters

Parameter

Description

Required

mfa

The combination of the authentication device's serial number, a space, and the value that is displayed on your authentication device.

The format of the mfa is:

"mfa":"arn:aws:iam::0123456789:mfa/username"

No

mfaDelete

Specifies whether MFA delete is enabled or disabled.

No

Example

<cfscript> 
  storageService = getCloudService(application.awsCred,application.s3Conf) 
  // create a bucket 
  createBucketRequest = { 
    "acl":"PRIVATE", 
    "bucket" : "bucket.demo.suspendversioning", 
    // to suspend versioning, turn off object locking for the bucket 
    "objectLockEnabledForBucket" : false 
  } 
  //  create a bucket 
  myobj=storageService.createBucket(createBucketRequest) 
  // enable versioning on the bucket 
  myobj.enableVersioning(); 
  // get the version status 
  versionStatus1=myobj.getVersioningStatus(); 
  writeDump(versionStatus1) 
  // suspend the versioning 
  myobj.suspendVersioning(); 
  versionStatus2=myobj.getVersioningStatus(); 
  writeDump(versionStatus2) 
</cfscript> 

S3 ACL bucket operations

Amazon S3 access control lists (ACLs) enable you to manage access to buckets and objects. Each bucket and object have an ACL attached to it as a sub-resource. It defines which AWS accounts or groups are granted access and the type of access. When a request is received against a resource, Amazon S3 checks the corresponding ACL to verify that the requester has the necessary access permissions.

When you create a bucket or an object, Amazon S3 creates a default ACL that grants the resource owner full control over the resource.

For more information, see S3 ACL.

putBucketAcl

Set the permissions on an existing bucket using access control lists (ACL).

For more information, see Using ACLs.

To set the ACL of a bucket, you must have WRITE_ACP permission.

Syntax

putBucketAcl(parameterStruct)

Parameters

Parameter

Description

Required

acl

Amazon S3 access control lists (ACLs) enable you to manage access to buckets and objects.

Valid values are:

  • PRIVATE: Only owner of the bucket has full control of the bucket and its objects.
  • PUBLIC_READ: Owner of the bucket has full control. Members of AllUsers group have READ rights to the bucket and its objects.
  • PUBLIC_READ_WRITE: Owner gets FULL_CONTROL. The AllUsers group gets READ and WRITE access.
  • AUTHENTICATED_READ: Owner gets FULL_CONTROL. The AuthenticatedUsers group gets READ access.

For more information, see ACLs in AWS.

No

grant permission variables

Permissions that Amazon S3 supports in an ACL.

Valid values are:

  • grantFullControl: Allows the grantee full control of the bucket.
  • grantRead: Allows the grantee to view the objects in the bucket.
  • grantWrite: Allows the grantee to create, overwrite, and delete any object in the bucket.
  • grantWriteACP: Allows the grantee to write the ACL for the bucket.
  • grantReadACP: Allows the grantee to read the ACL permissions for the bucket.

For more information, see Permissions.

No

Example

<cfscript> 
  storageService = getCloudService(this.s3Cred,this.s3Conf) 
  createBucketRequest1 = { 
       "bucket" : "cfqa.003" 
       } 
  rootObj = storageService.createRoot(createBucketRequest1); 
  putBucketAclRequest = { 
      "acl" : "PRIVATE" 
  } 
  putBucketAclResponse=rootObj.putBucketAcl(putBucketAclRequest); 
  writeDump(putBucketAclResponse) 
</cfscript> 

Example with grant permissions.

<cfscript> 
    storageService = getCloudService(application.awsCred,application.s3Conf) 
    createBucketRequest1 = { 
       "bucket" : "cfqa.003" 
       } 
    rootObj = storageService.createRoot(createBucketRequest1) 
    putBucketAclRequest = { 
        "grantFullControl": "emailAddress=john@example.com", 
        // "grantFullControl": "id=f1db27629293ee8354a2874de1959b39bec20ffe98417b931fb381f97007cf97" 
        "grantReadACP" : "uri=http://acs.amazonaws.com/groups/s3/LogDelivery" 
    } 
    putBucketAclResponse=rootObj.putBucketAcl(putBucketAclRequest); 
    writeDump(putBucketAclResponse) 
</cfscript>

getBucketAcl

Use this function to get a list of ACLs in a bucket.

For more information, see the getBucketAcl official docs.

Syntax

getBucketAcl()

Example

<cfscript> 
  storageService = getCloudService(this.s3Cred,this.s3Conf) 
  createBucketRequest1 = { 
     "bucket" : "cfqa.004", 
     "grantFullControl": "uri=http://acs.amazonaws.com/groups/global/AuthenticatedUsers" 
     } 
  rootObj = storageService.createRoot(createBucketRequest1); 
  getBucketAclResponse=rootObj.getBucketAcl() 
  writeDump(getBucketAclResponse) 
</cfscript>

putObjectAcl

The function uses the ACL sub-resource to set the access control list (ACL) permissions for an object that already exists in a bucket.

In putObjectAcl, there is an extra attribute “key”: ”object_key” in the struct.

For more information, see the official docs.

Syntax

putObjectAcl(parameterStruct)

Parameters

Parameter

Description

Required

acl

Amazon S3 access control lists (ACLs) enable you to manage access to buckets and objects.

Valid values are:

  • PRIVATE: Only owner of the bucket has full control of the bucket and its objects.
  • PUBLIC_READ: Owner of the bucket has full control. Members of AllUsers group have READ rights to the bucket and its objects.
  • PUBLIC_READ_WRITE: Owner gets FULL_CONTROL. The AllUsers group gets READ and WRITE access.
  • AUTHENTICATED_READ: Owner gets FULL_CONTROL. The AuthenticatedUsers group gets READ access.

For more information, see ACLs in AWS.

No

grant permission variables

Permissions that Amazon S3 supports in an ACL.

Valid values are:

  • grantFullControl: Allows the grantee full control of the bucket.
  • grantRead: Allows the grantee to view the objects in the bucket.
  • grantWrite: Allows the grantee to create, overwrite, and delete any object in the bucket.
  • grantWriteACP: Allows the grantee to write the ACL for the bucket.

For more information, see Permissions.

No

key

The key for the operation.

Yes

Example

<cfscript> 
    storageService = getCloudService(application.awsCred,application.s3Conf) 
    // create a bucket 
    createBucketRequest = { 
        "bucket" : "bucket.putobjectacl.demo" 
    } 
    bucketObj = storageService.createBucket(createBucketRequest) 
    // upload an object 
    uploadStruct = { 
        "srcFile" : "#ExpandPath('./')#/s3-notes.pdf", 
        "key" : "key12" 
    } 
    bucketObj.uploadFile(uploadStruct) 
    // put ACL on the object 
    putObjectAclRequest = { 
        "key" : "key12", 
        "acl" : "PRIVATE" 
    } 
    try{ 
        objectAclResponse=bucketObj.putObjectAcl(putObjectAclRequest) 
        writeOutput("ACL applied successfully on the object") 
        writeDump(objectAclResponse) 
    } 
    catch(any e){ 
        writeOutput("Unable to apply ACL on the object") 
        writeDump(e) 
    } 
    putObjectAclResponse=bucketObj.GetObjectAcl("key12") 
    writeDump(putObjectAclResponse) 
</cfscript>

getObjectAcl

Return the access control list (ACL) of an object.

To use this operation, you must have READ_ACP access to the object.

Syntax

getObjectAcl(parameterStruct)

Parameters

Parameter

Description

Required

key

The key of the object for which to get the ACL information.

Yes

versionId

Refer to a specific version of the object.

No

Example

<cfscript> 
    storageService = getCloudService(application.awsCred,application.s3Conf) 
    // create a bucket 
    createBucketRequest = { 
        "bucket" : "bucket.putobjectacl.demo" 
    } 
    bucketObj = storageService.createBucket(createBucketRequest) 
    // upload an object 
    uploadStruct = { 
        "srcFile" : "#ExpandPath('./')#/s3-notes.pdf", 
        "key" : "key12" 
    } 
    bucketObj.uploadFile(uploadStruct) 
    // put ACL on the object 
    putObjectAclRequest = { 
        "key" : "key12", 
        "acl" : "PRIVATE" 
    } 
    try{ 
        objectAclResponse=bucketObj.putObjectAcl(putObjectAclRequest) 
        writeOutput("ACL applied successfully on the object") 
        writeDump(objectAclResponse) 
    } 
    catch(any e){ 
        writeOutput("Unable to apply ACL on the object") 
        writeDump(e) 
    } 
    putObjectAclResponse=bucketObj.getObjectAcl("key12") 
    writeDump(putObjectAclResponse) 
</cfscript>

Lifecycle rules

Lifecycle rule that defines how AWS s3 manages objects during their lifetime. There are two types of actions:

  1. Transition actions—Define when objects transition to another storage class.
  2. Expiration actions—Define when objects expire. Amazon S3 deletes expired objects on your behalf.

 Define lifecycle configuration rules for objects that have a well-defined lifecycle. For example:

  • Some documents are frequently accessed for a limited period. After that, they are infrequently accessed. At some point, you might not need real-time access to them, but your organization or regulations might require you to archive them for a specific period. After that, you can delete them.
  • You might upload some types of data to Amazon S3 primarily for archival purposes. For example, you might archive digital media, financial and healthcare records, raw genomic sequence data, long-term database backups, and data that must be retained for regulatory compliance.
  • If you upload periodic logs to a bucket, your application might need them for a week or a month. After that, you might want to delete them.

setRules

You can use setRules function to set lifecycle rules to objects in the bucket. The function accepts the following struct as argument.

"rules" :  
    [ 
        { 
            "id" : "rule1", 
            "prefix" : "a/b", 
            "lifecycleRuleFilter" :  
            { 
                "prefix" : "", 
                "tagging" :  
                { 
                    "key": "", 
                    "value" : "" 
                }, 
                "lifecycleRuleAndOperator" :  
                { 
                    "prefix" : "", 
                    "tagging" :  
                    [{ 
                        "key": "", 
                        "value" : "" 
                    }] 
                } 
            }, 
 
            "status" : "ENABLED", 
            "expiration" :  
            { 
                "date" : "YYYY-MM-DD", 
                "days" : 3 
            }, 
            "noncurrentVersionExpirationDays" : 30, 
            "noncurrentVersionTransitions" : 
            [ { 
                "days" : 35, 
                "storageClass" : "GLACIER" 
            }], 
            "abortIncompleteMultipartUploadInDays" : 7, 
            "transitions" : [ 
                { 
                    "days" : 90, 
                    "storageClass" : "ONEZONE_IA" 
                } 
            ] 
        } 
    ]

The following is not supported in ColdFusion (2021 release). It will be supported in a future update.

"lifecycleRuleFilter" :  
            { 
                "prefix" : "", 
                "tagging" :  
                { 
                    "key": "", 
                    "value" : "" 
                }, 
                "lifecycleRuleAndOperator" :  
                { 
                    "prefix" : "", 
                    "tagging" :  
                    [{ 
                        "key": "", 
                        "value" : "" 
                    }] 
                } 
            }

Example 1

<cfscript> 
    storageService = getCloudService(application.awsCred,application.s3Conf) 
    deleteStruct = { 
        "bucket" : "bucket.rule.append1", 
        "forcedDelete" : "true" 
    } 
     
    // Adding lifecycle rules by specifying date 
     
    // create a bucket 
    createBucketRequest = { 
        "acl":"PRIVATE", 
        "bucket" : "bucket.rule.four", 
        "objectLockEnabledForBucket" : true 
    } 
    bucketObj=storageService.createBucket(createBucketRequest) 
    // upload an object to the bucket 
    uploadStruct={ 
        "srcFile":"#ExpandPath('./')#/s3-notes.pdf", 
        "key":"key114" 
    } 
    bucketObj.uploadFile(uploadStruct) 
    exp_date=DateFormat(DateAdd("d",8,now()),"yyyy-mm-dd") 
 trans_date=DateFormat(DateAdd("d",2,now()),"yyyy-mm-dd") 
     
 ruleStruct = { 
     "rules" :  
         [{ 
             "id" : "rule1", 
             "prefix":"key", 
             "status" : "ENABLED", 
             "expiration" : { 
                 "date":exp_date 
             }, 
             "transitions" :  
                     [{ 
              "date":trans_date, 
                  "storageClass" : "ONEZONE_IA" 
                     }] 
                      
         }] 
    } 
    try{ 
        bucketObj.setRules(ruleStruct) 
        writeOutput("Lifecycle rule set successfully") 
        rules=bucketObj.getRules().rules 
  writedump(rules) 
    } 
    catch(any e){ 
        writeOutput("Unable to set lifecycle") 
        writeDump(e) 
    } 
</cfscript>

Example 2

<cfscript> 
    storageService = getCloudService(application.awsCred,application.s3Conf) 
     
    createBucketRequest = { 
        "acl":"PRIVATE", 
        "bucket" : "bucket.rule.three", 
        "objectLockEnabledForBucket" : true 
    } 
    bucketObj=storageService.createBucket(createBucketRequest) 
    // upload an object to the bucket 
    uploadStruct={ 
        "srcFile":"#ExpandPath('./')#/s3-notes.pdf", 
        "key":"key112" 
    } 
    bucketObj.uploadFile(uploadStruct) 
    ruleStruct={ 
        "rules":[{ 
            "id" : "rule1", 
         "prefix":"key", 
         "status" : "ENABLED", 
         "noncurrentVersionTransitions" :  
          [{ 
       "days":30, 
       "storageClass" : "INTELLIGENT_TIERING" 
          }] 
        }] 
    } 
    try{ 
        bucketObj.setRules(ruleStruct) 
        writeOutput("Lifecycle rule set successfully") 
        //writeDump(setRuleResponse) 
        // rules=bucketObj.getRules().rules 
  // writedump(rules) 
    } 
    catch(any e){ 
        writeOutput("Unable to set lifecycle") 
        writeDump(e) 
    } 
</cfscript>

appendRules

You can use the method appendRules to add the rules to the existing set of rules. The function accepts the following struct as argument.

"rules" :  
    [ 
        { 
            "id" : "rule1", 
            "prefix" : "a/b", 
            "lifecycleRuleFilter" :  
            { 
                "prefix" : "", 
                "tagging" :  
                { 
                    "key": "", 
                    "value" : "" 
                }, 
                "lifecycleRuleAndOperator" :  
                { 
                    "prefix" : "", 
                    "tagging" :  
                    [{ 
                        "key": "", 
                        "value" : "" 
                    }] 
                } 
            }, 
  
            "status" : "ENABLED", 
            "expiration" :  
            { 
                "date" : "YYYY-MM-DD", 
                "days" : 3 
            }, 
            "noncurrentVersionExpirationDays" : 30, 
            "noncurrentVersionTransitions" : 
            [ { 
                "days" : 35, 
                "storageClass" : "GLACIER" 
            }], 
            "abortIncompleteMultipartUploadInDays" : 7, 
            "transitions" : [ 
                { 
                    "days" : 90, 
                    "storageClass" : "ONEZONE_IA" 
                } 
            ] 
        } 
    ]

The following is not supported in ColdFusion (2021 release). It will be supported in a future update.

"lifecycleRuleFilter" :  
            { 
                "prefix" : "", 
                "tagging" :  
                { 
                    "key": "", 
                    "value" : "" 
                }, 
                "lifecycleRuleAndOperator" :  
                { 
                    "prefix" : "", 
                    "tagging" :  
                    [{ 
                        "key": "", 
                        "value" : "" 
                    }] 
                } 
            }

Example

<cfscript> 
  storageService = getCloudService(this.s3Cred,this.s3Conf) 
  rules={ 
  "rules" : [ 
                              { 
                                  "id" : "rule1", 
                                  "prefix" : "a/b", 
                                  "status" : "ENABLED", 
                                  "expiration" : { 
                                      //"date" : "DD/MM/YYY", 
                                      "days" : 3 
                                  }, 
                                  "noncurrentVersionExpirationDays" : 30, 
                                  "noncurrentVersionTransitions" :[ { 
                                      "days" : 35, 
                                      "storageClass" : "GLACIER" 
                                   }], 
                                   "abortIncompleteMultipartUploadInDays" : 7, 
                                   "transitions" : [ 
                                      { 
                                          "days" : 90, 
                                          "storageClass" : "ONEZONE_IA" 
                                      } 
                                   ] 
                              } 
                          ] 
  } 
  createBucketRequest = { 
      "acl":"PRIVATE", 
       "bucket" : "cf.bucket", 
       "objectLockEnabledForBucket" : true 
  } 
  rootObj=storageService.createBucket(createBucketRequest) 
  appendRulesResponse=rootObj.appendRules(rules) 
  writeDump(appendRulesResponse) 
</cfscript>

getRules

You can use the getRules function to retrieve all lifecycle rules for the bucket. This function does not accept any argument.

Example

<cfscript> 
    storageService = getCloudService(application.awsCred,application.s3Conf) 
    // create a bucket 
    createBucketRequest = { 
        "acl":"PRIVATE", 
        "bucket" : "bucket.rule.delete", 
        "objectLockEnabledForBucket" : true 
    } 
    bucketObj=storageService.createBucket(createBucketRequest) 
    // upload an object to the bucket 
    uploadStruct={ 
        "srcFile":"#ExpandPath('./')#/s3-notes.pdf", 
        "key":"key100" 
    } 
    bucketObj.uploadFile(uploadStruct) 
    // create rule 
    ruleStruct={ 
        "rules":[{ 
            "id" : "rule1", 
         "prefix":"key", 
         "status" : "ENABLED", 
         "noncurrentVersionTransitions" :  
          [{ 
       "days":30, 
       "storageClass" : "INTELLIGENT_TIERING" 
          }] 
        }] 
    } 
    // set the rule 
    bucketObj.setRules(ruleStruct) 
    // get the rule 
    rules=bucketObj.getRules().rules 
    writeDump(rules) 
</cfscript>

Add tags to a bucket

Object tagging gives you a way to categorize storage.

For more information, see the official docs.

Syntax

addTags(parameterStruct)

Parameters

Parameter

Description

Required

key

Unique identifier of the object.

Yes

versionId

Refer to a specific version of the object.

No

tags

Array of tag structs.

Yes

Example

<cfscript> 
  storageService = getCloudService(application.awsCred,application.s3Conf) 
  // create bucket 
  createBucketRequest = { 
       "acl":"PRIVATE", 
       "bucket" : "bucket.demoaddtagstest", 
       "objectLockEnabledForBucket" : true 
  } 
  bucketobj=storageService.createBucket(createBucketRequest) 
  // upload a file 
  uploadStruct = { 
      "srcFile" : "#ExpandPath('./')#/s3-notes.pdf", 
      "key" : "key12" 
  } 
  bucketobj.uploadFile(uploadStruct) 
  // add tags to the object 
  addTagStruct={ 
    "key" : "key12", 
    "tags" : [ 
            { 
            "key" : "label", 
            "value" : "red" 
            }, 
            { 
                "key": "category", 
                "value": "important" 
            } 
    ] 
  } 
  try{ 
      addTagResponse=bucketobj.addTags(addTagStruct) 
      writeOutput("Tags added successfully") 
      writeDump(addTagResponse) 
  } 
  catch(any e){ 
      writeOutput("Failed to add tags") 
      writeDump(e) 
  } 
</cfscript>

Get tags of an object

Retrieve the list of tags that you’d added to the bucket. Use the getTagObjects function.

This function accepts the key that you’d specified while adding the tags.

Syntax

getTagObjects(parameterStruct)

Parameters

Parameter

Description

Required

key

Unique identifier of the object.

Yes

versionId

Refer to a specific version of the object.

No

Example

<cfscript> 
  storageService = getCloudService(application.awsCred,application.s3Conf) 
  // create bucket 
  createBucketRequest = { 
      "acl":"PRIVATE", 
      "bucket" : "bucket.demoaddtagstest", 
      "objectLockEnabledForBucket" : true 
  } 
  bucketobj=storageService.createBucket(createBucketRequest) 
  // upload a file 
  uploadStruct = { 
    "srcFile" : "#ExpandPath('./')#/s3-notes.pdf", 
    "key" : "key12" 
  } 
  bucketobj.uploadFile(uploadStruct) 
// add tags to the object 
  addTagStruct={ 
 "key" : "key12", 
 "versionId":"v1", 
 "tags" : [ 
         { 
         "key" : "label", 
         "value" : "red" 
         }, 
         { 
             "key": "category", 
             "value": "important" 
         } 
 ] 
} 
  getTagResponse=bucketobj.GettagObjects("key12") 
  writeDump(getTagResponse) 
</cfscript> 

Get object details

Get details of an object that was uploaded in a bucket.

Syntax

getObjectDetails(parameterStruct)

Parameters

Parameter Description Required
srcFile
The path of the file that you want to upload in the bucket. Yes
key
Unique identifier of the object. Yes
acl

The ACL to apply to the object. For more information, see Canned ACL.The valid values are:

  • PRIVATE
  • PUBLIC_READ
  • PUBLIC_READ_WRITE
  • AUTHENTICATED_READ
  • AWS_EXEC_READ
  • BUCKET_OWNER_READ
  • BUCKET_OWNER_FULL_CONTROL
No
cacheControl
Specify the caching behavior as defined here. No
contentDisposition
Specify the content format of the object as defined here. No
contentEncoding
Specify the type of encoding on the object as defined here. No
contentLanguage
The language of the object that you want to upload. No
contentLength
The size of the object in bytes. No
validateContentMD5
True or False. The base64-encoded 128-bit MD5 digest of the message (without the headers).
No
contentType
The format of the content as defined here. No
expires
The date and time when the object cannot be cached any longer.
No
grantFullControl
Gives the grantee READ, READ_ACP, and WRITE_ACP permissions on the object.
No
grantRead
Allows grantee to only read the object data.
No
grantWrite
Allows grantee to write to the object data.
No
grantReadACP
Allows grantee to read the object ACL.
No
grantWriteACP
Allows grantee to write the ACL for the object.
No
metadata
The object metadata to use. No
serverSideEncryption
The server-side encryption algorithm to be used.
No
storageClass

Valid values are:

  • STANDARD
  • REDUCED_REDUNDANCY
  • STANDARD_IA
  • ONEZONE_IA
  • INTELLIGENT_TIERING
  • GLACIER
  • DEEP_ARCHIVE

For more information, see S3 storage class.

No
websiteRedirectLocation
If the bucket is configured as a website, specify the redirect request to another object in the same bucket or to an external URL.
No
sseCustomerAlgorithm
Specifies the algorithm to use to when encrypting the object.
No
sseCustomerKey
Specifies the customer-provided encryption key for S3 to use in encrypting data. 
No
ssekmsKeyId
Specifies the ID of the AWS Key Management Service (AWS KMS).
No
ssekmsEncryptionContext
Specifies the AWS KMS Encryption Context to use for object encryption. 
No
requestPayer
Confirms that the requester knows that they will be charged for the request.
No
tagging
The tag-set for the object. Must be a struct of key-value pairs.
No
objectLockMode

The Object locking mode that you want to apply to this object. Valid values are:

  • GOVERNANCE
  • COMPLIANCE
No
objectLockRetainUntilDate
The date and time when you want this object's Object Lock to expire.
No
objectLockLegalHoldStatus

Indicates whether the specified object has a Legal Hold in place.. Valid values are:

  • ON
  • OFF
No

Example

<cfscript> 
    storageService = getcloudService(application.awsCred,application.s3Conf) 
    // create a bucket 
    bucketStruct={ 
        "acl":"PRIVATE", 
        "bucket" : "bucket.demo.objectdetailsdemo", 
        "objectLockEnabledForBucket" : true 
    } 
    bucketObj=storageService.createBucket(bucketStruct) 
    // upload an object into the bucket 
    uploadStruct = { 
             "srcFile" : "#ExpandPath('./')#/Colors.jpg", 
        "key" : "key001", 
             "metadata": { 
                        "filename": "Colors.jpg", 
                        "creator":"john", 
                        "place":"london", 
                        "creation_date":"2020/04/20", 
                        "filetype":"image" 
        }, 
             "contentLanguage":"en", 
             "websiteRedirectLocation":"http://bucket", 
             "expires":"2020-05-28"  
         } 
    bucketObj.uploadFile(uploadStruct) 
    // get object details 
    objectDetailsResponse=bucketObj.getObjectDetails("key001") 
    writeDump(objectDetailsResponse) 
</cfscript>

Upload file parallelly

You can upload objects in a bucket in parts, or parallelly. You can use parallel uploads for objects from 5 MB to 5 TB in size. If you're uploading large objects over a stable high-bandwidth network, use parallel uploading to make better use of your available bandwidth by uploading object parts in parallel for multi-threaded performance.

Syntax

parallelUploadFile(parameterStruct)

Parameters

Parameter Description Required
srcFile The location of the file that you want to upload. Yes
chunkLengthInBytes Size of the content chunk. No
timeOutInSeconds The time out of the upload operation. No
acl

Amazon S3 access control lists (ACLs) enable you to manage access to buckets and objects.

Valid values are:

  • PRIVATE
  • PUBLIC_READ
  • PUBLIC_READ_WRITE
  • AUTHENTICATED_READ
  • AWS_EXEC_READ
  • BUCKET_OWNER_READ
  • BUCKET_OWNER_FULL_CONTROL
No
cacheControl Specify the caching behavior as defined here. No
contentDisposition Specify the content format of the object as defined here. No
contentEncoding Specify the type of encoding on the object as defined here. No
contentLanguage The language of the object that you want to upload. No
contentLength The size of the object in bytes. No
validateContentMD5 :  True | False. The base64-encoded 128-bit MD5 digest of the message (without the headers). No
contentType The format of the content as defined here. No
expires The date and time when the object cannot be cached any longer. No
grantFullControl Gives the grantee READ, READ_ACP, and WRITE_ACP permissions on the object. No
grantRead Allows grantee to read the object ACL. No
grantReadACP Allows grantee to read the object ACL. No
grantWriteACP Allows grantee to write the ACL for the object. No
metadata The object metadata to use. No
serverSideEncryption The server-side encryption algorithm to be used. No
storageClass

Valid values are:

  • STANDARD
  • REDUCED_REDUNDANCY
  • STANDARD_IA
  • ONEZONE_IA
  • INTELLIGENT_TIERING
  • GLACIER
  • DEEP_ARCHIVE

For more information, see S3 storage class.

No
websiteRedirectLocation If the bucket is configured as a website, specify the redirect request to another object in the same bucket or to an external URL. No
sseCustomerAlgorithm Specifies the algorithm to use to when encrypting the object. No
sseCustomerKey Specifies the customer-provided encryption key for S3 to use in encrypting data.  No
sseCustomerKeyMD5 Specifies the MD5 of the key. No
ssekmsKeyId Specifies the ID of the AWS Key Management Service (AWS KMS). No
ssekmsEncryptionContext Specifies the AWS KMS Encryption Context to use for object encryption.  No
requestPayer Confirms that the requester knows that they will be charged for the request. No
tagging  NOTE: This will be supported from s3 sdk 2.10.46 onwards. No
objectLockMode

The Object locking mode that you want to apply to this object. Valid values are:

  • GOVERNANCE
  • COMPLIANCE
 
objectLockRetainUntilDate The date and time when you want this object's Object Lock to expire. No
          objectLockLegalHoldStatus

Indicates whether the specified object has a Legal Hold in place.. Valid values are:

  • ON
  • OFF
No

Example

<cfscript> 
    storageService = getCloudService(application.awsCred,application.s3Conf) 
    // create a bucket 
     
 createBucketRequest = { 
  "bucket" : "bucket.parallel.upload" 
    } 
    rootObj = storageService.createBucket(createBucketRequest) 
    // parallel upload struct 
    parallelUploadRequest = { 
        "srcFile" : "#ExpandPath('..')#/files/file.txt", 
        "chunkLengthInBytes": "5e+6", 
        "timeOutInSeconds": "60", 
        "key": "key1"         
    } 
    try{ 
        uploadResponse = rootObj.parallelUploadFile(parallelUploadRequest) 
        writeOutput("Parallel upload successful") 
        writeDump(uploadResponse) 
    } 
    catch(any e){ 
        writeDump(e) 
    } 
</cfscript>

Download file parallelly

Once you’ve uploaded a large object in a bucket, you can then download the object parallelly, in parts.

Syntax

parallelDownloadFile(parameterStruct)

Parameters

Parameter Description Required
key The key with which an object was uploaded. Yes
destinationFile The location where you want to download the file to. Yes
chunkLengthInBytes Size of the content chunk. No
cacheControl
Set the cache control header of the object, No
contentDisposition
Set the Content-Disposition header of the response.
No
contentEncoding
Set the Content-Encoding header of the response.
No
contentLanguage
Set the Content-Language header of the response.
No
contentType
Set the Content-Type header of the response.
No
expires
Sets the Response header of the response.
No
versionId
Refer to a specific version of the object. No
sseCustomerAlgorithm
Specify the algorithm to use to when encrypting the object.
No
sseCustomerKey
Specify the customer-provided encryption key for S3 to use in encrypting data.
No
requestPayer
Confirms that the requester knows that they will be charged for the request.
No

Example

<cfscript> 
    storageService = cloudService(application.awsCred,application.s3Conf) 
    // create a bucket 
     
 createBucketRequest = { 
  "bucket" : "bucket.parallel.download" 
    } 
    rootObj = storageService.createBucket(createBucketRequest) 
     
    // parallel upload struct 
    parallelUploadRequest = { 
        "srcFile" : "#ExpandPath('..')#/files/file.txt", 
        "chunkLengthInBytes": "5e+6", 
        "timeOutInSeconds": "60", 
        "key": "key1"         
    } 
    // upload object parallelly 
    rootObj.parallelUploadFile(parallelUploadRequest) 
    // parallel download struct 
    parallelDownloadRequest = { 
        "key" : "key1", 
        "destinationFile" : "file.txt", 
        "chunkLengthInBytes": "5e+6" 
    } 
    downloadResponse=rootObj.parallelDownloadFile(parallelDownloadRequest) 
    writeDump(downloadResponse) 
</cfscript>

Multi-part upload of files

Multipart upload allows you to upload a single object as a set of parts. Each part is a contiguous portion of the object's data.

You can upload these object parts independently and in any order.

For more information, see Multi-part uploads in AWS.

Syntax

multipartUpload(parameterStruct)

Parameters

Parameter Description Required
srcFile The location of the file that you want to upload. Yes
chunkLengthInBytes Size of the content chunk. No
timeOutInSeconds The time out of the upload operation. No
acl

Amazon S3 access control lists (ACLs) enable you to manage access to buckets and objects.

Valid values are:

  • PRIVATE
  • PUBLIC_READ
  • PUBLIC_READ_WRITE
  • AUTHENTICATED_READ
  • AWS_EXEC_READ
  • BUCKET_OWNER_READ
  • BUCKET_OWNER_FULL_CONTROL
No
cacheControl Specify the caching behavior as defined here. No
contentDisposition Specify the content format of the object as defined here. No
contentEncoding Specify the type of encoding on the object as defined here. No
contentLanguage The language of the object that you want to upload. No
contentLength The size of the object in bytes. No
validateContentMD5 :  True | False. The base64-encoded 128-bit MD5 digest of the message (without the headers). No
contentType The format of the content as defined here. No
expires The date and time when the object cannot be cached any longer. No
grantFullControl Gives the grantee READ, READ_ACP, and WRITE_ACP permissions on the object. No
grantRead Allows grantee to read the object ACL. No
grantReadACP Allows grantee to read the object ACL. No
grantWriteACP Allows grantee to write the ACL for the object. No
metadata The object metadata to use. No
serverSideEncryption The server-side encryption algorithm to be used. No
storageClass

Valid values are:

  • STANDARD
  • REDUCED_REDUNDANCY
  • STANDARD_IA
  • ONEZONE_IA
  • INTELLIGENT_TIERING
  • GLACIER
  • DEEP_ARCHIVE

For more information, see S3 storage class.

No
websiteRedirectLocation If the bucket is configured as a website, specify the redirect request to another object in the same bucket or to an external URL. No
sseCustomerAlgorithm Specifies the algorithm to use to when encrypting the object. No
sseCustomerKey Specifies the customer-provided encryption key for S3 to use in encrypting data.  No
sseCustomerKeyMD5 Specifies the MD5 of the key. No
ssekmsKeyId Specifies the ID of the AWS Key Management Service (AWS KMS). No
ssekmsEncryptionContext Specifies the AWS KMS Encryption Context to use for object encryption.  No
requestPayer Confirms that the requester knows that they will be charged for the request. No
tagging  NOTE: This will be supported from s3 sdk 2.10.46 onwards. No
objectLockMode

The Object locking mode that you want to apply to this object. Valid values are:

  • GOVERNANCE
  • COMPLIANCE
 
objectLockRetainUntilDate The date and time when you want this object's Object Lock to expire. No
          objectLockLegalHoldStatus

Indicates whether the specified object has a Legal Hold in place.. Valid values are:

  • ON
  • OFF
No

Example

<cfscript> 
    storageService = cloudService(application.awsCred,application.s3Conf) 
    // create a bucket 
     
 createBucketRequest = { 
  "bucket" : "bucket.parallel.multipartupload" 
    } 
    rootObj = storageService.createBucket(createBucketRequest) 
    // multi part upload struct 
    mulitipartUploadRequest = { 
        "srcFile" : "#ExpandPath('..')#/files/file.mp4", 
        "chunkLengthInBytes": "5e+6", 
        "timeOutInSeconds": "2", 
        "key": "key1"         
    } 
    try{ 
        uploadResponse = rootObj.multipartUpload(mulitipartUploadRequest) 
        writeOutput("File uploaded sucessfully in multiple parts") 
        writeDump(uploadResponse) 
    } 
    catch(any e){ 
        writeDump(e) 
    } 
</cfscript>

Upload an object

Upload an object to a bucket.

Syntax

uploadObject(parameterStruct)

Parameters

Parameter Description Required
key
Unique identifier of the object. Yes
acl

The ACL to apply to the object. For more information, see Canned ACL.The valid values are:

  • PRIVATE
  • PUBLIC_READ
  • PUBLIC_READ_WRITE
  • AUTHENTICATED_READ
  • AWS_EXEC_READ
  • BUCKET_OWNER_READ
  • BUCKET_OWNER_FULL_CONTROL
No
cacheControl
Specify the caching behavior as defined here. No
contentDisposition
Specify the content format of the object as defined here. No
contentEncoding
Specify the type of encoding on the object as defined here. No
contentLanguage
The language of the object that you want to upload. No
contentLength
The size of the object in bytes. No
validateContentMD5
The base64-encoded 128-bit MD5 digest of the message (without the headers).
No
contentType
The format of the content as defined here. No
expires
The date and time when the object cannot be cached any longer.
No
grantFullControl
Gives the grantee READ, READ_ACP, and WRITE_ACP permissions on the object.
No
grantRead
Allows grantee to only read the object data.
No
grantWrite
Allows grantee to write to the object data.
No
grantReadACP
Allows grantee to read the object ACL.
No
grantWriteACP
Allows grantee to write the ACL for the object.
No
metadata
The object metadata to use. No
serverSideEncryption
The server-side encryption algorithm to be used.
No
storageClass

Valid values are:

  • STANDARD
  • REDUCED_REDUNDANCY
  • STANDARD_IA
  • ONEZONE_IA
  • INTELLIGENT_TIERING
  • GLACIER
  • DEEP_ARCHIVE

For more information, see S3 storage class.

No
websiteRedirectLocation
If the bucket is configured as a website, specify the redirect request to another object in the same bucket or to an external URL.
No
sseCustomerAlgorithm
Specifies the algorithm to use to when encrypting the object.
No
sseCustomerKey
Specifies the customer-provided encryption key for S3 to use in encrypting data. 
No
ssekmsKeyId
Specifies the ID of the AWS Key Management Service (AWS KMS).
No
ssekmsEncryptionContext
Specifies the AWS KMS Encryption Context to use for object encryption. 
No
requestPayer
Confirms that the requester knows that they will be charged for the request.
No
tagging
The tag-set for the object. Must be a struct of key-value pairs.
No
objectLockMode

The Object locking mode that you want to apply to this object. Valid values are:

  • GOVERNANCE
  • COMPLIANCE
No
objectLockRetainUntilDate
The date and time when you want this object's Object Lock to expire.
No
object Object to be uploaded. No
type Object type- json No
useCustomSerializer

True or False. Whether to use the custom serializer or not. The default value is true. The custom serializer will be always used for XML deserialization. If false, the XML/JSON deserialization will be done using the default ColdFusion behavior. If any other type is passed with useCustomSerializer as false, then TypeNotSupportedException will be thrown.

For more information, see Serialize.

No
objectLockLegalHoldStatus

Indicates whether the specified object has a Legal Hold in place.. Valid values are:

  • ON
  • OFF

Example

<cfscript> 
    storageService = getCloudService(application.awsCred,application.s3Conf) 
    // create the bucket 
    rootObj=storageService.bucket("bucket.download.object","true") 
    key = "key12" 
 a=["a","b","c","d"]; 
    // define upload struct 
    uploadStruct = { 
     "type": "json", 
     "object" : a, 
     "key" : key 
    } 
    // upload an object 
    try{ 
        rootObj.uploadObject(uploadStruct) 
        writeOutput("Object uploaded successfully") 
    } 
    catch(any e){ 
        writeOutput("Failed to upload object") 
        writeDump(e) 
    } 
    // define download struct 
    downloadStruct = { 
        "type": "json", 
        "key" : key 
    } 
    // download the object 
    try{ 
        rootObj.downloadObject(downloadStruct) 
        writeOutput("Object downloaded successfully") 
    } 
    catch(any e){ 
        writeOutput("Failed to download object") 
        writeDump(e) 
    } 
</cfscript>

Download an object

Download an object that was uploaded previously.

Syntax

downloadObject(parameterStruct)

Parameters

Parameter Description Required
key
Unique identifier of the object. Yes
cacheControl
Set the cache control header of the object, No
contentDisposition
Set the Content-Disposition header of the response.
No
contentEncoding
Set the Content-Encoding header of the response.
No
contentLanguage
Set the Content-Language header of the response.
No
contentType
Set the Content-Type header of the response.
No
expires
Sets the Response header of the response.
No
versionId
Refer to a specific version of the object. No
sseCustomerAlgorithm
Specify the algorithm to use to when encrypting the object.
No
sseCustomerKey
Specify the customer-provided encryption key for S3 to use in encrypting data.
No
requestPayer
Confirms that the requester knows that they will be charged for the request.
No
type Object type- json No
useCustomSerializer True or False No

Example

<cfscript> 
    storageService = getCloudService(application.awsCred,application.s3Conf) 
    // create the bucket 
    rootObj=storageService.bucket("bucket.download.object","true") 
    key = "key12" 
 a=["a","b","c","d"]; 
    // define upload struct 
    uploadStruct = { 
     "type": "json", 
     "object" : a, 
     "key" : key 
    } 
    // upload an object 
    try{ 
        rootObj.uploadObject(uploadStruct) 
        writeOutput("Object uploaded successfully") 
    } 
    catch(any e){ 
        writeOutput("Failed to upload object") 
        writeDump(e) 
    } 
    // define download struct 
    downloadStruct = { 
        "type": "json", 
        "key" : key 
    } 
    // download the object 
    try{ 
        rootObj.downloadObject(downloadStruct) 
        writeOutput("Object downloaded successfully") 
    } 
    catch(any e){ 
        writeOutput("Failed to download object") 
        writeDump(e) 
    } 
</cfscript>

Upload a directory

Upload a directory in a bucket. You can also perform a bulk upload.

Syntax

uploadDirectory(parameterStruct)

Parameters

Parameter

Description

Required

prefix

It is the prefix that will be added to the object key while uploading.

Yes

sourceDirectory

The location of the directory to upload.

Yes

uploadNestedDirectory

True or False. Specify if you want to include sub-directories inside the main folder.

No

Example

<cfscript> 
    storageService = getCloudService(application.awsCred,application.s3Conf) 
    // create a bucket 
    createBucketRequest = { 
        "acl":"PRIVATE", 
        "bucket" : "bucket.b.four", 
        "objectLockEnabledForBucket" : true 
    } 
    bucketObj=storageService.createBucket(createBucketRequest) 
    // define request parameters for upload 
    dirUploadReq = { 
        "prefix" : "test_bulk\", 
        "sourceDirectory" : "../files", 
        "uploadNestedDirectory" : true 
    } 
    try{ 
        uploadResponse=storageService.uploadDirectory(dirUploadReq) 
        writeOutput("Directory uploaded successfully") 
        writeDump(uploadResponse) 
    } 
    catch(any e){ 
        writeDump(e) 
    } 
  </cfscript>

PutObjectLockConfiguration

Place an Object Lock configuration on the specified bucket.

For more information, see the official docs.

Syntax

putObjectLockConfiguration(parameterStruct)

Parameters

Parameter

Description

Required

objectLockConfiguration

The root level tag for the ObjectLockConfiguration parameters.

Yes

objectLockEnabled

Whether this bucket has an Object Lock configuration enabled. Valid values are: ENABLED

No

defaultRetention

Struct containing the following:

mode: The Object locking mode that you want to apply to this object. Valid values are:

  • GOVERNANCE
  • COMPLIANCE

days: Number of days to lock the object for.

years: Number of years to lock the object for.

Note: Specify either days or years, not both.

No

Example

<cfscript> 
    storageService = getCloudService(application.awsCred,application.s3Conf) 
    
    // create a bucket 
    createBucketRequest = { 
        "acl":"PRIVATE", 
        "bucket" : "bucket.demo.getobjectlock", 
        "objectLockEnabledForBucket" : true 
    } 
    // create a bucket 
    bucketObj=storageService.createBucket(createBucketRequest) 
    // upload an object to the bucket 
    uploadStruct={ 
        "srcFile":"#ExpandPath('./')#/s3-notes.pdf", 
        "key":"key161" 
    } 
    bucketObj.uploadFile(uploadStruct) 
    // put object lock 
    putObjectLockRequest = { 
        "objectLockConfiguration" : { 
            "objectLockEnabled" : "ENABLED", 
            "defaultRetention" : { 
                "mode" : "GOVERNANCE", 
                "days" : 31 
            } 
        } 
    } 
    bucketObj.putObjectLockConfiguration(putObjectLockRequest) 
    // get object lock 
    objectLockResponse=bucketObj.getObjectLockConfiguration() 
    writeDump(objectLockResponse) 
</cfscript>

getObjectLockConfiguration

Get the Object Lock configuration for a bucket.

For more information, see the official docs.

Syntax

getObjectLockConfiguration()

Example

<cfscript> 
    storageService = getCloudService(application.awsCred,application.s3Conf) 
    
    // create a bucket 
    createBucketRequest = { 
        "acl":"PRIVATE", 
        "bucket" : "bucket.demo.getobjectlock", 
        "objectLockEnabledForBucket" : true 
    } 
    // create a bucket 
    bucketObj=storageService.createBucket(createBucketRequest) 
    // upload an object to the bucket 
    uploadStruct={ 
        "srcFile":"#ExpandPath('./')#/s3-notes.pdf", 
        "key":"key161" 
    } 
    bucketObj.uploadFile(uploadStruct) 
    // put object lock 
    putObjectLockRequest = { 
        "objectLockConfiguration" : { 
            "objectLockEnabled" : "ENABLED", 
            "defaultRetention" : { 
                "mode" : "GOVERNANCE", 
                "days" : 31 
            } 
        } 
    } 
    bucketObj.putObjectLockConfiguration(putObjectLockRequest) 
    // get object lock 
    objectLockResponse=bucketObj.getObjectLockConfiguration() 
    writeDump(objectLockResponse) 
</cfscript>

acquireLegalHold

Apply a Legal Hold to object.

For more information, see Locking Objects and the official doc.

Syntax

acquireLegalHold(parameterStruct)

Parameters

Parameter

Description

Required

key

The key name for the object that you want to place a Legal Hold on.

Yes

versionId

The version ID of the object that you want to place a Legal Hold on.

No

legalHold

The root level tag for the LegalHold parameters. Struct containing the following:

status: ON or OFF

No

requestPayer

Confirms that the requester knows that they will be charged for the request. Valid value is: REQUESTER

No

Example

<cfscript> 
    storageService = getCloudService(application.awsCred,application.s3Conf) 
     
    // create a bucket 
    createBucketRequest = { 
        "acl":"PRIVATE", 
        "bucket" : "bucket.demo.acquirelegalhold", 
        "objectLockEnabledForBucket" : true 
    } 
    // create a bucket 
    bucketObj=storageService.createBucket(createBucketRequest) 
    // upload an object to the bucket 
    uploadStruct={ 
        "srcFile":"#ExpandPath('./')#/s3-notes.pdf", 
        "key":"key121" 
    } 
    bucketObj.uploadFile(uploadStruct) 
    // enable versioning 
    bucketObj.enableVersioning() 
    // list all versions 
    list=bucketObj.listAllVersions() 
    // get version Id 
    v_id=list.response[1].versionId 
    // acquire legal hold request 
    acquireLegalHoldRequest = { 
        "key" : "key121", 
        "versionId" : "#v_id#", 
        "legalHold" : { 
            "status" : "ON" 
        }, 
        "requestPayer" : "REQUESTER" 
    } 
    try{ 
        acquireHoldResponse=bucketObj.acquireLegalHold(acquireLegalHoldRequest) 
        writeDump(acquireHoldResponse) 
    } 
    catch (any e){ 
        writeDump(e) 
    } 
</cfscript>

getLegalHold

Apply a Legal Hold to object.

For more information, see Locking Objects.

Syntax

getLegalHold(parameterStruct)

Parameters

Parameter

Description

Required

key

The key name for the object whose Legal Hold status you want to get.

Yes

versionId

The version ID of the object whose Legal Hold status you want to get.

No

requestPayer

Confirms that the requester knows that they will be charged for the request. Valid value is: REQUESTER

No

Example

<cfscript> 
    storageService = getCloudService(application.awsCred,application.s3Conf) 
    createBucketRequest = { 
        "acl":"PRIVATE", 
        "bucket" : "bucket.demo.getlegalhold", 
        "objectLockEnabledForBucket" : true 
    } 
    // create a bucket 
    bucketObj=storageService.createBucket(createBucketRequest) 
    // upload an object to the bucket 
    uploadStruct={ 
        "srcFile":"#ExpandPath('./')#/s3-notes.pdf", 
        "key":"key141" 
    } 
    bucketObj.uploadFile(uploadStruct) 
    // enable versioning 
    bucketObj.enableVersioning() 
    // list all versions 
    list=bucketObj.listAllVersions() 
    // get version Id 
    v_id=list.response[1].versionId 
    // get legal hold status on the object 
    getLegalHoldRequest = { 
        "key" : "key141", 
        "versionId" : "#v_id#", 
        "requestPayer" : "REQUESTER" 
    } 
    getLegalHoldResponse=bucketObj.getLegalHold(getLegalHoldRequest) 
    writeDump(getLegalHoldResponse) 
</cfscript>

Acquire retention lock

Place an Object Retention configuration on an object.

For more information, see the official docs.

Syntax

acquireRetentionLock(parameterStruct)

Parameters

Parameter

Description

Required

key

The key name for the object that you want to apply this Object Retention configuration to.

Yes

versionID

The version ID for the object that you want to apply this Object Retention configuration to.

No

retention

Struct containing the following:

  • mode: Retention mode for the specified object. Values are GOVERNANCE or COMPLIANCE.
  • retainUntilDate: The date on which this Object Lock Retention will expire.

No

requestPayer

Confirms that the requester knows that he/she will be charged for the request.

No

bypassGovernanceRetention

Whether this operation must bypass Governance-mode restrictions.

 

Example

<cfscript> 
    storageService = getCloudService(application.awsCred,application.s3Conf) 
    createBucketRequest = { 
        "acl":"PRIVATE", 
        "bucket" : "bucket.demo.acquireretentionlock", 
        "objectLockEnabledForBucket" : true 
    } 
    // create a bucket 
    bucketObj=storageService.createBucket(createBucketRequest) 
    // upload an object to the bucket 
    uploadStruct={ 
        "srcFile":"#ExpandPath('./')#/s3-notes.pdf", 
        "key":"key131" 
    } 
    bucketObj.uploadFile(uploadStruct) 
    // enable versioning 
    bucketObj.enableVersioning() 
    // list all versions 
    list=bucketObj.listAllVersions() 
    // get version Id 
    v_id=list.response[1].versionId 
    retainDate=DateFormat(DateAdd("d",8,now()),"yyyy-mm-dd") 
    retentionRequestStruct = { 
       "key" : "key131", 
       "versionId" : "#v_id#", 
       "retention" : { 
            "mode" : "GOVERNANCE", 
            "retainUntilDate" : "#retainDate#" 
       }, 
       "requestPayer" : "REQUESTER", 
       "bypassGovernanceRetention" : false 
    } 
    try{ 
        acquireRetentionLockResponse=bucketObj.acquireRetentionLock(retentionRequestStruct) 
        writeDump(acquireRetentionLockResponse) 
    } 
    catch(any e){ 
        writeDump(e) 
    } 
</cfscript>

Get retention lock

Retrieve an object's retention settings.

Syntax

getRetentionLock(parameterStruct)

Parameters

Parameter

Description

Required

key

The key name for the object for which you want to retrieve this Object Retention configuration.

Yes

versionId

The version id for the object for which you want to retrieve this Object Retention configuration.

No

requestPayer

Confirms that the requester knows that he/she will be charged for the request. Valid value is: REQUESTER

No

Example

<cfscript> 
    storageService = getCloudService(application.awsCred, application.s3Conf) 
     
    createBucketRequest = { 
         "bucket" : "bucket.demo.lock", 
         "objectLockEnabledForBucket" : "true"  
        } 
    rootObj=storageService.createBucket(createBucketRequest) 
    //rootObj=storageService.bucket("cfqa2.test123456",true); 
     
    rootObj.enableVersioning() 
    // upload a file 
    uploadRequest = { 
            "srcFile" : "test.txt",  
            "key" : "test", 
            "validateContentMD5":"true", 
            "objectLockMode" : "GOVERNANCE", 
            "objectLockRetainUntilDate" : "2019-12-11", 
            "objectLockLegalHoldStatus" : "ON" 
    } 
    rootObj.uploadFile(uploadRequest); 
    //writedump(uploadResponse) 
 
  
    request1 = { 
        "objectLockConfiguration" : { 
        "objectLockEnabled" : "ENABLED", 
        "defaultRetention" : { 
                "mode" : "GOVERNANCE", 
                "days" : "2", 
                "years": "1" 
            } 
        } 
    } 
    
    rootObj.putObjectLockConfiguration(request1) 
    retentionRequest = { 
        "key" : "test", 
         "retention" : { 
            "mode" : "GOVERNANCE", 
            "retainUntilDate" : "{ts '2019-11-27 12:13:50'}" 
    }, 
    "bypassGovernanceRetention" :"true" 
    } 
    rootObj.acquireRetentionLock(retentionRequest) 
    getRetentionRequest={ 
        "key" : "test" 
    } 
    writedump(rootObj.getRetentionLock(getRetentionRequest)) 
</cfscript>

Requester Pay

In general, bucket owners pay for the storage and data transfer costs associated with their bucket. A bucket owner can configure a bucket to be a Requester Pays bucket. With Requester Pays buckets, the requester instead of the bucket owner pays the cost of the request and the data download from the bucket. The bucket owner always pays the cost of storing data.

Typically, you configure buckets to be Requester Pays when you want to share data but not incur charges associated with others accessing the data. You might, for example, use Requester Pays buckets when making available large datasets, such as zip code directories, reference data, geospatial information, or web crawling data.

If you enable Requester Pays on a bucket, anonymous access to that bucket is not allowed.

You must authenticate all requests involving Requester Pays buckets. The request authentication enables Amazon S3 to identify and charge the requester for their use of the Requester Pays bucket.

enableRequesterPay

Enable requester pay on a bucket.

Syntax

enableRequesterpay()

Example

<cfscript> 
  storageService = getCloudService(application.awsCred,application.s3Conf) 
  // create a bucket 
  createBucketRequest = { 
    "acl":"PRIVATE", 
    "bucket" : "sg.bucket", 
    "objectLockEnabledForBucket" : true 
  } 
  // create a bucket 
  myobj=storageService.createBucket(createBucketRequest) 
  // Enabling "Requester Pays" on bucket: 
  myobj.enableRequesterpay() 
  // Get Requester Pay status: 
  getResponse=myobj.getRequesterPayStatus() 
  writeDump(getResponse) 
</cfscript> 

disableRequesterPay

Disable requester pay on a bucket.

Syntax

disableRequesterPay()

Example

<cfscript> 
    storageService = getCloudService(application.awsCred,application.s3Conf) 
    // create a bucket 
    createBucketRequest = { 
        "acl":"PRIVATE", 
        "bucket" : "bucket.demo.disablerequester", 
        "objectLockEnabledForBucket" : true 
    } 
    // create a bucket 
    bucketObj=storageService.createBucket(createBucketRequest) 
    // Enabling "Requester Pays" on bucket 
    bucketObj.enableRequesterpay() 
    // Disable requester pay status on the bucket 
    try{ 
        disableRequesterPayResponse=bucketObj.disableRequesterPay() 
        writeOutput("Requester pay disabled") 
        writeDump(disableRequesterPayResponse) 
    } 
    catch (any e){ 
        writeOutput("Unable to disable requester pay") 
        writeDUmp(e) 
    } 
</cfscript>

getRequesterPayStatus

Check if requester pay is enabled on bucket.

Syntax

getRequesterPayStatus()

Example

<cfscript> 
    storageService = cloudService(application.awsCred,application.s3Conf) 
    // create a bucket 
    createBucketRequest = { 
        "acl":"PRIVATE", 
        "bucket" : "bucket.demo.getrequester", 
        "objectLockEnabledForBucket" : true 
    } 
    // create a bucket 
    bucketObj=storageService.createBucket(createBucketRequest) 
    // Enabling "Requester Pays" on bucket 
    bucketObj.enableRequesterpay() 
    // Get the requester pay details 
    getRequesterPayResponse=bucketObj.getRequesterPayStatus() 
    writeDump(getRequesterPayResponse) 
</cfscript>

Security

AWS provides Identity and Access Management (IAM) user policies that specify the users that can access specific buckets and objects.

AWS S3 provides writing bucket policies that define access to specific buckets and objects. You can use a bucket policy to grant access across AWS accounts, grant public or anonymous permissions, and allow or block access based on conditions.

Using Amazon S3 Block Public Access as a centralized way to limit public access. Block Public Access settings override bucket policies and object permissions. Be sure to enable Block Public Access for all accounts and buckets that you don't want publicly accessible.

Amazon S3 block public access provides four settings. You can apply these settings in any combination to individual buckets or to entire AWS accounts. If you apply a setting to an account, it applies to all buckets that are owned by that account.

putSecurityAccessBlock

Block public access on bucket. For more information, see Public access block.

Syntax

putSecurityAccessBlock(parameterStruct)

Parameters

Parameter

Description

Required

blockPublicAcls

TRUE or FALSE. Whether S3 must block public access control lists (ACLs) for this bucket and objects in this bucket.

No

ignorePublicAcls

TRUE or FALSE. Whether S3 must ignore public access control lists (ACLs) for this bucket and objects in this bucket.

No

blockPublicPolicy

TRUE or FALSE. Whether S3 must block public bucket policies for this bucket.

No

restrictPublicBuckets

TRUE or FALSE. Whether S3 must restrict public bucket policies for this bucket.

No

Example

<cfscript> 
    storageService = getCloudService(application.awsCred,application.s3Conf) 
    // create a bucket 
    createBucketRequest = { 
        "acl":"PRIVATE", 
        "bucket" : "bucket.demo.getpublicaccess", 
        "objectLockEnabledForBucket" : true 
    } 
    bucketobj=storageService.createBucket(createBucketRequest) 
    pubAccessReq = { 
        "publicAccessBlockConfiguration" : { 
            "blockPublicAcls" : true, 
            "ignorePublicAcls" : true, 
            "blockPublicPolicy" : true, 
            "restrictPublicBuckets" : true 
        } 
    } 
    try{ 
        accessBlockResponse=bucketobj.putSecurityAccessBlock(pubAccessReq) 
        writeOutput("Block to public access enforced successfully") 
        writeDump(accessBlockResponse) 
    } 
    catch(any e){ 
        writeOutput("Failed to block public access") 
        writeDump(e) 
    } 
    // get the block details 
    getBlockResponse=bucketobj.getSecurityAccessBlock() 
    writeDump(getBlockResponse) 
</cfscript>

getSecurityAccessBlock

Get public access configuration on bucket. For more information, see Get public access block.

Syntax

getSecurityAccessBlock()

Example

<cfscript> 
    storageService = getCloudService(application.awsCred,application.s3Conf) 
    // create a bucket 
    createBucketRequest = { 
        "acl":"PRIVATE", 
        "bucket" : "bucket.demo.getpublicaccess", 
        "objectLockEnabledForBucket" : true 
    } 
    bucketobj=storageService.createBucket(createBucketRequest) 
    pubAccessReq = { 
        "publicAccessBlockConfiguration" : { 
            "blockPublicAcls" : true, 
            "ignorePublicAcls" : true, 
            "blockPublicPolicy" : true, 
            "restrictPublicBuckets" : true 
        } 
    } 
    try{ 
        accessBlockResponse=bucketobj.putSecurityAccessBlock(pubAccessReq) 
        writeOutput("Block to public access enforced successfully") 
        writeDump(accessBlockResponse) 
    } 
    catch(any e){ 
        writeOutput("Failed to block public access") 
        writeDump(e) 
    } 
    // get the block details 
    getBlockResponse=bucketobj.getSecurityAccessBlock() 
    writeDump(getBlockResponse) 
</cfscript>

Get location of an S3 bucket

Get the region that contains a bucket.

For more information, see Get bucket location.

Syntax

getLocation()

Example

<cfscript> 
    storageService = getCloudService(application.awsCred, application.s3Conf) 
    // create a bucket 
    createBucketRequest = { 
        "acl":"PRIVATE", 
        "bucket" : "bucket.demo.loc", 
        "objectLockEnabledForBucket" : true 
    } 
    // create a bucket 
    bucketObj=storageService.createBucket(createBucketRequest) 
    // get bucket location 
    bucketLoc=bucketObj.getLocation() 
    writeDump(bucketLoc) 
</cfscript>

Get metadata of an object

Get the metadata of an object in a bucket. While uploading an object, you'd have already set the object's metadata.

Syntax

getObjectMetadata(parameterStruct)

Parameters

Parameter

Description

Required

key

The key with which the object was uploaded.

Yes

versionId

The version id associated with the object.

No

Example

<cfscript> 
    storageService = cloudService(application.awsCred,application.s3Conf) 
    // create a bucket 
    bucketStruct={ 
        "acl":"PRIVATE", 
        "bucket" : "bucket.demo.objectmetadatademo", 
        "objectLockEnabledForBucket" : true 
    } 
    bucketObj=storageService.createBucket(bucketStruct) 
    // upload an object into the bucket 
    uploadStruct={ 
        "srcFile" : "#ExpandPath('./')#/Colors.jpg", 
        "key" : "key001", 
        "metadata": { 
                        "filename": "Colors.jpg", 
                        "creator":"john", 
                        "place":"london", 
                        "creation_date":"2020/04/20", 
                        "filetype":"image" 
        } 
    } 
    bucketObj.uploadFile(uploadStruct) 
    // get object metadata 
    objectMetadataResponse=bucketObj.getObjectMetadata("key001") 
    writeDump(objectMetadataResponse) 
</cfscript>

Pre-signed URL

A pre-signed URL gives you access to the object identified in the URL, provided that the creator of the pre-signed URL has permissions to access that object. If you receive a pre-signed URL to upload an object, you can upload the object only if the creator of the pre-signed URL has the necessary permissions to upload that object.

For more information, see Uploading objects using pre-signed urls.

generateGetPresignedUrl

Generate a url to get an object.

Syntax

generateGetPresignedUrl(parameterStruct)

Parameters

Parameter Description Required
duration Duration of the url in days. No
key The key associated with the object. Yes
cacheControl
Specify the caching behavior as defined here. No
contentDisposition
Specify the content format of the object as defined here. No
contentEncoding
Specify the type of encoding on the object as defined here. No
contentLanguage
The language of the object that you want to upload. No
contentType
The format of the content as defined here. No
expires
The date and time when the object cannot be cached any longer.
No
versionId The version id of the object. No
sseCustomerAlgorithm
Specifies the algorithm to use to when encrypting the object.
No
sseCustomerKey
Specifies the customer-provided encryption key for S3 to use in encrypting data. 
No
sseCustomerKeyMD5 Specifies the MD5 of the key. No
requestPayer Confirms that the requester knows that they will be charged for the request. No

Example

<cfscript> 
    storageService = getCloudService(application.awsCred,application.s3Conf) 
    // create a bucket 
     
 createBucketRequest = { 
  "bucket" : "bucket.parallel.getpresignedurl" 
    } 
    rootObj = storageService.createBucket(createBucketRequest) 
    // upload a file 
    src = "#ExpandPath('..')#/files/file.txt" 
 key = "key12" 
       
 uploadStruct = { 
     "srcFile" : src, 
     "key" : key  
    } 
    rootObj.uploadFile(uploadStruct) 
    // Pre signed url struct 
    getPresignedUrlRequest = { 
        "duration": "1d", // 1 day 
        "key":key 
    } 
    getPresignedUrlResp = rootObj.generateGetPresignedUrl(getPresignedUrlRequest) 
    writeDump(getPresignedUrlResp) 
</cfscript>

generatePutPresignedUrl

Generates a url to put an object.

Syntax

generatePutPresignedUrl(parameterStruct)

Parameters

Parameter

Description

Required

duration

Duration of the url in days.

No

key

The key associated with the object.

Yes

Example

<cfscript> 
    storageService = getCloudService(application.awsCred,application.s3Conf) 
    // create a bucket 
     
 createBucketRequest = { 
  "bucket" : "bucket.parallel.putpresignedurl" 
    } 
    rootObj = storageService.createBucket(createBucketRequest) 
    putPresignedReq = { 
        "duration": "1d", // 1 day 
        "key" : "key12" 
     } 
    putPresignedUrlResp = rootObj.generatePutPresignedUrl(putPresignedReq);  
    writedump(putPresignedUrlResp) 
</cfscript>

Get help faster and easier

New user?