0

I am trying to set the cache control to no-cache on S3 uploads but the header is not being set. I tried the below in the upload script which didn't work.

request: {
            endpoint: "https://",
            accessKey: "",
            customHeaders: "Cache-Control: no-cache"
        },

Then I also tried adding it to the S3 handler php file like this ( added to the bottom)

 // Only needed in cross-origin setups
function handlePreflight() {
 handleCorsRequest();
 header('Access-Control-Allow-Methods: POST');
 header('Access-Control-Allow-Headers: Content-Type');
header('Access-Control-Allow-Headers: Cache-Control');

plus I thenm also added it here

function signRequest() {
header('Content-Type: application/json');
header('Cache-Control: no-cache');

neither by themselves nor or all of them together made the header appear on uploaded file.

So I am not sure what I am doing wrong

  • Oh, I am using 5.3 commercial. I noticed a previous thread that it wasn't working in a much earlier version. – Mark Shueard Sep 20 '15 at 05:28
  • A few questions: which thread are you referring to? Why are you trying to add this header? What does "doesn't work" mean in this case exactly? – Ray Nicholus Sep 20 '15 at 08:39
  • Here is one http://stackoverflow.com/questions/24460467/supplying-headers-to-amazon-s3-with-fineuploader – Mark Shueard Sep 20 '15 at 08:42
  • But I found another I can't seem to find now, where you said it would be fixed soon. It was some time ago. I would like to add the cache control - no cache to make sure a page is loaded with the latest xml file that was uploaded from the fineuploader. The xml file is an rss file and must not be cahced – Mark Shueard Sep 20 '15 at 08:44
  • doesnt work means that when I look at the file in clouberry explorer S3 the http header cache control is absent – Mark Shueard Sep 20 '15 at 08:45

2 Answers2

3

To set custom headers for S3. Use 'request.params' instead of 'request.customHeaders'. For e.g(in this case try using the below one)


request: {
            endpoint: "https://endpoint.url.here",
            accessKey: "access-key-here",
            params: {"Cache-Control": "no-cache"}
        },


To know more refer the docs.

nilay jha
  • 744
  • 8
  • 12
0

Your last two examples would not have any affect on the object in S3. Instead, they would only influence the response to Fin Uploader's signature request. Your first example is incorrectly formed. The request.customHeaders option expects an object value.

Regardless, you can't currently pass these types of headers on to the S3 object via Fine Uploader S3. See https://github.com/FineUploader/fine-uploader/pull/1258 for details & updates.

Ray Nicholus
  • 19,538
  • 14
  • 59
  • 82
  • Ok, only x-amz then it seems. Thanks – Mark Shueard Sep 22 '15 at 14:10
  • The last comment in that issue thread is dated July 2015. As it is now October 2015, has there been any movement on this? It is very important for my use case as a paid license holder that I am able to set headers like `Cache-Control` on the files I upload to S3. – Vidya Oct 11 '15 at 15:29