class S3 extends AnyRef

Optimized for read-mostly AWS S3 buckets; uses caching to speed access. To clear the caches after a invoking method that caches its response, either the app must be restarted or the clearCaches method must be called. Methods that are cached are denoted by cached.

When uploading, any leading slashes for keys are removed because when AWS S3 is enabled for a web site, S3 adds a leading slash.

Keys of assets that were uploaded by other clients might start with leading slashes, or a dash; those assets can not be fetched by web browsers.

When web site access to an S3 bucket is enabled, AWS content is accessed by paths constructed by concatenating the URL, a slash (/), and the keyed data. The keys must therefore consist of relative paths (relative directory name followed by a file name), and must not start with a leading slash. awslib_scala stores each file name (referred to by AWS as a key) without a leading slash. For example, assuming that the default file name is index.html, then http://domain.com and http://domain.com/ are translated to http://domain.com/index.html.

As another example, the key for a file in a directory called <WEBROOT>/blah/ick/yuck.html is defined as blah/ick/yuck.html.

AWS does not respect the last-modified metadata provided when uploading; it uses the upload timestamp instead. After uploading, the last-modified timestamp of the uploaded file is read and applied to the local copy of the file so the timestamps match.

Java on Windows does not handle last-modified properly, so the creation date is set to the last-modified date for files (Windows only).

For each directory, AWS creates a file of the same name, with the suffix _$folder$. If one of those files are deleted, the associated directory becomes unreachable. Don't mess with them. These hidden files are ignored by awslib_scala; users never see them because they are for AWS S3 internal use only.

Source
S3.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. S3
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new S3()

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. val _allObjectData: Memoizer[(String, String), List[S3ObjectSummary]]
    Attributes
    protected
  5. val _bucketExists: Memoizer[String, Boolean]
    Attributes
    protected
  6. val _bucketLocation: Memoizer[String, String]
    Attributes
    protected
  7. val _bucketNames: Memoizer0[List[String]]
    Attributes
    protected
  8. def _bucketNamesWithDistributions(cf: CloudFront): List[String]
    Attributes
    protected
  9. val _bucketsWithDistributions: Memoizer[CloudFront, List[Bucket]]
    Attributes
    protected
  10. val _findByName: Memoizer[String, Option[Bucket]]
  11. val _isWebsiteEnabled: Memoizer[String, Boolean]

    Requires property com.amazonaws.sdk.disableCertChecking to have a value (any value will do)

  12. val _listObjectsByPrefix: Memoizer[(String, String, String, Boolean), List[String]]
  13. val _oneObjectData: Memoizer[(String, String), Option[S3ObjectSummary]]
  14. val _resourceUrl: Memoizer[(String, String, Option[CloudFrontAlias]), String]
  15. def allObjectData(bucketName: String, prefix: String): List[S3ObjectSummary]

    cached

    cached

    prefix

    Any leading slashes are removed if a prefix is specified

    returns

    collection of S3ObjectSummary; keys are relativized if prefix is adjusted

  16. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  17. def bucketExists(bucketName: String): Boolean
  18. def bucketLocation(bucketName: String): String

    cached

  19. def bucketNames: List[String]

    cached List the buckets in the account.

  20. def bucketNamesWithDistributions(implicit cf: CloudFront): Memoizer[CloudFront, List[String]]

    cached Either the memo cache must be cleared, or the app must be restarted if a bucket or distribution is created after this method is called, or the bucket or distribution will never be found

  21. def bucketsWithDistributions(implicit cf: CloudFront): List[Bucket]

    Either the memo cache must be cleared, or the app must be restarted if a bucket or distribution is created after this method is called, or the bucket or distribution will never be found

  22. val cacheIsDirty: AtomicBoolean
  23. def clearCaches(): Unit
  24. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate() @throws( ... )
  25. def createBucket(bucketName: String): Bucket

    Create a new S3 bucket.

    Create a new S3 bucket. If the bucket name starts with "www.", make it publicly viewable and enable it as a web site. Amazon S3 bucket names are globally unique, so once a bucket repoName has been taken by any user, you can't create another bucket with that same repoName. You can optionally specify a location for your bucket if you want to keep your data closer to your applications or users.

  26. def deleteBucket(bucketName: String): Unit

    Delete a bucket – the bucket will automatically be emptied if necessary so it can be deleted.

    Delete a bucket – the bucket will automatically be emptied if necessary so it can be deleted.

    Annotations
    @throws( classOf[AmazonClientException] )
  27. def deleteObject(bucketName: String, key: String): Unit

    Delete an object – if they key has any leading slashes, they are removed.

    Delete an object – if they key has any leading slashes, they are removed. Unless versioning has been turned on for the bucket, there is no way to undelete an object.

  28. def deletePrefix(bucketName: String, prefix: String): Unit

    Normal use case is to delete a directory and all its contents

  29. def disableWebsite(bucketName: String): Unit
  30. def downloadFile(bucketName: String, key: String): InputStream

    Download an object – if the key has any leading slashes, they are removed.

    Download an object – if the key has any leading slashes, they are removed. When you download an object, you get all of the object's metadata and a stream from which to read the contents. It is important to read the contents of the stream as quickly as possible since the data is streamed directly from Amazon S3 and the network connection will remain open until all the data is read or the input stream is closed.

    GetObjectRequest also supports several other options, including conditional downloading of objects based on modification times, ETags, and selectively downloading a range of an object; none of these are used.

  31. def emptyBucket(bucketName: String): Unit
    Annotations
    @throws( classOf[AmazonClientException] )
  32. def enableCors(bucket: Bucket): Unit

    Cross-Origin Resource Sharing

    Cross-Origin Resource Sharing

    See also

    https://en.wikipedia.org/wiki/Cross-origin_resource_sharing

    <?xml version="1.0" encoding="UTF-8"?>
      <CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
          <CORSRule>
              <AllowedOrigin>*</AllowedOrigin>
              <AllowedMethod>GET</AllowedMethod>
              <AllowedMethod>HEAD</AllowedMethod>
              <AllowedMethod>PUT</AllowedMethod>
              <AllowedMethod>POST</AllowedMethod>
              <AllowedMethod>DELETE</AllowedMethod>
              <AllowedHeader>*</AllowedHeader>
          </CORSRule>
      </CORSConfiguration>
  33. def enableWebsite(bucketName: String, errorPage: String): Unit
  34. def enableWebsite(bucketName: String): Unit
  35. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  36. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  37. def findByName(bucketName: String): Option[Bucket]

    cached

  38. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate()
  39. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate()
  40. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  41. def isWebsiteEnabled(bucketName: String): Boolean

    cached

  42. def listObjectsByPrefix(bucketName: String, prefix: String, suffix: String = "", showSize: Boolean = false): List[String]

    ** cached ** List objects in given bucketName by prefix; number of bytes is included if showSize is true.

    ** cached ** List objects in given bucketName by prefix; number of bytes is included if showSize is true.

    prefix

    Any leading slashes are removed if a prefix is specified

    suffix

    optional secondary filter

  43. def move(oldBucketName: String, oldKey: String, newBucketName: String, newKey: String): Unit

    Move oldKey in bucket with bucketName to newBucket / newKey.

    Move oldKey in bucket with bucketName to newBucket / newKey. Object metadata is preserved.

  44. def move(bucketName: String, oldKey: String, newKey: String): Unit

    Move oldKey in bucket with bucketName to newKey.

    Move oldKey in bucket with bucketName to newKey. Object metadata is preserved.

  45. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  46. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate()
  47. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate()
  48. def oneObjectData(bucketName: String, prefix: String): Option[S3ObjectSummary]

    cached

    cached

    prefix

    Any leading slashes are removed if a prefix is specified

    returns

    Option[ObjectSummary] with leading "./", prepended if necessary

  49. implicit val s3: S3
  50. implicit val s3Client: AmazonS3Client
  51. def sanitizedPrefix(key: String): String
  52. def setBucketPolicy(bucket: Bucket, policyJson: String): Bucket

    This method is idempotent Side effect: sets policy for AWS S3 upload bucket

  53. def setBucketPolicy(bucket: Bucket, statements: List[Statement]): Bucket

    This method is idempotent Side effect: sets policy for AWS S3 upload bucket

  54. def setContentType(key: String, metadata: ObjectMetadata): ObjectMetadata
  55. def setContentType(key: String): ObjectMetadata
  56. def signUrl(bucket: Bucket, url: URL, minutesValid: Int = 60, useHttps: Boolean = false, maybeCnameAlias: Option[String] = None): URL

    useHttps

    is only used if maybeCnameAlias is None

  57. def signUrlStr(bucket: Bucket, key: String, minutesValid: Int = 0, useHttps: Boolean = false, maybeCnameAlias: Option[String] = None): URL

    useHttps

    is only used if maybeCnameAlias is None

  58. def staticResourceUrl(bucketName: String, key: String)(implicit maybeAlias: Option[StaticCFAlias]): String

    cached The cache must be cleared or the app must be restarted if a bucket is created or the referenced CloudFront distribution alias is created (by assigning a CNAME) after this method is first called, or the distribution with the desired cname will never be found

  59. def streamingResourceUrl(bucketName: String, key: String)(implicit maybeAlias: Option[StreamingCFAlias]): String

    cached The cache must be cleared or the app must be restarted if a bucket is created or the referenced CloudFront distribution alias is created (by assigning a CNAME) after this method is first called, or the distribution with the desired cname will never be found

  60. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  61. def toString(): String
    Definition Classes
    AnyRef → Any
  62. def uploadFile(bucketName: String, key: String, file: File, showProgress: Boolean = false): PutObjectResult

    Uploads a file to the specified bucket using the REST interface that backs the Java facade.

    Uploads a file to the specified bucket using the REST interface that backs the Java facade. The file's last-modified date is applied to the uploaded file. AWS does not respect the last-modified metadata, and Java on Windows does not handle last-modified properly either. If the key has leading slashes, they are removed for consistency.

    AWS does not respect the last-modified metadata provided when uploading; it uses the upload timestamp instead. After uploading, the last-modified timestamp of the uploaded file is read and applied to the local copy of the file so the timestamps match.

    Java on Windows does not handle last-modified properly, so the creation date is set to the last-modified date (Windows only).

    To list the last modified date with seconds in bash with: ls -lc --time-style=full-iso To list the creation date with seconds in bash with: ls -l --time-style=full-iso

  63. def uploadFileOrDirectory(bucketName: String, dest: String, file: File): Unit

    Recursive upload to AWS S3 bucket

    Recursive upload to AWS S3 bucket

    dest

    path to copy to on AWS S3

    file

    or directory to copy

  64. def uploadStream(bucketName: String, key: String, stream: InputStream, length: Int): Unit

    key

    if the key has any leading slashes, they are removed

    See also

    ObjectMetadata

  65. def uploadString(bucketName: String, key: String, contents: String): PutObjectResult
  66. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  67. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  68. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @Deprecated @deprecated @throws( classOf[java.lang.Throwable] )
    Deprecated

    (Since version ) see corresponding Javadoc for more information.

  2. def resourceUrl(bucketName: String, key: String): String

    cached The cache must be cleared or the app must be restarted if a bucket is created after this method is first called, or the bucket will never be found

    cached The cache must be cleared or the app must be restarted if a bucket is created after this method is first called, or the bucket will never be found

    Annotations
    @deprecated
    Deprecated

    (Since version 1.0.4) Use staticResourceUrl or streamingResourceUrl instead

Inherited from AnyRef

Inherited from Any

Ungrouped