README.md in saviour-0.4.3 vs README.md in saviour-0.4.4
- old
+ new
@@ -265,11 +265,35 @@
This storage includes a feature of overwrite protection, raising an exception if an attempt is made of writing something
on a path that already exists. This behaviour in enabled by default, but you can turn it off by passing an additional
argument when instantiating the storage: `overwrite_protection: false`. This feature requires an additional HEAD request
to verify existence for every write.
+NOTE: Be aware that S3 has a limit of 1024 bytes for the keys (paths) used. Be sure to truncate to that maximum length
+if you're using an s3 storage, for example with a processor like this:
+```ruby
+ # http://docs.aws.amazon.com/AmazonS3/latest/dev/UsingMetadata.html
+ # Max 1024 bytes for keys in S3
+ def truncate_at_max_key_size(contents, filename)
+ # Left 20 bytes of margin (up to 1024) to have some room for a name
+ if store_dir.bytesize > 1004
+ raise "The store_dir used is already bigger than 1004 bytes, must be reduced!"
+ end
+
+ key = "#{store_dir}#{filename}"
+ new_filename = if key > 1024
+ # note mb_chars is an active support's method
+ filename.mb_chars.limit(1024 - store_dir.bytesize).to_s
+ else
+ filename
+ end
+
+ [contents, new_filename]
+ end
+```
+
+
## Source abstraction
As mentioned before, you can use `File#assign` with any io like object that responds to `read` and `rewind`. This is already the case for `::File`,
`Tempfile` or `IO`. Since a file requires also a filename, however, in those cases a random filename will be assigned
(you can always set the filename using a processor later on).
@@ -381,9 +405,11 @@
beginning and at the end, for writing and reading to and from a file.
When using `process_with_file`, the last file instance you return from your last processor defined as
`process_with_file` will be automatically deleted by Saviour. Be aware of this if you return
some File instance different than the one you received pointing to a file.
+
+From inside a process you can also access the current store dir with `store_dir`.
Finally, processors can be disabled entirely via a configuration parameter. Example:
```
Saviour::Config.processing_enabled = false