In my previous post, we went through the process of creating and activating a file gateway. Then, created a SMB share enabling guest authentication. Mapped that SMB share and uploaded files to mapped drive which are transferred to S3 bucket.
But, what if I upload files directly to S3 bucket, will they be available on the client mapped drive? Lets find out, I am going to use AWS CLI instead of web console to demonstrate this. If you want to setup AWS CLI with your access key IDs, please check this: https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html
In the below screenshots, we can see my S3 bucket aws-filegateway with one file named HelloFile.txt available on S3 bucket and the file share under mount drive Z:


Now, lets upload a file to S3 bucket and verify if its available on the Z network drive. Using aws s3 cp, I uploaded the file to S3 bucket but that file is not available on my mapped network drive Z.

For the files uploaded to S3 to be available from the client share, we would need to run RefreshCache. You can do it from the console as here : https://docs.aws.amazon.com/storagegateway/latest/userguide/managing-gateway-file.html#refresh-cache
I will do it from the CLI to show you further on how to run a RefreshCache on a particular S3 folder instead of the whole bucket and the contents under the root of the bucket.
To get the file share ARN, run : aws storagegateway list-file-shares
To run RefreshCache : aws storagegateway refresh-cache –file-share-arn <fileshare ARN>
Since we have only one file and no new folders added on S3, the RefreshCache is completed quickly and we can see the S3file.txt on the network share Z.

Once the RefreshCache command is run, you would get the notification ID as the output. When you run the command, your RefreshCache request would be started and doesn’t mean that it is completed. If you have large number of hierarchical folders/files, it would take some time. To get notified when the RefreshCache operation is completed, you can configure CloudWatch notification with SNS : https://docs.aws.amazon.com/storagegateway/latest/userguide/monitoring-file-gateway.html#get-notification
Now, lets try to use FolderList parameter of RefreshCache to run the request targeting a certain folder in S3 bucket. I am going to create a folder with name Folder1 from the client. Folder1 is empty and doesn’t have any files.

Then, I uploaded S3file.txt file to that Folder1 and another file named S3file2 to the root of the bucket directly using aws s3 cp command.



Now, I will run the refresh cache only on the Folder1 so that the file name S3file.txt which is added under Folder1 would be available to use on client side. The S3file2 which is added under the root of the bucket wouldn’t be available as we are targeting the specific folder with name Folder1.

Running the dir command on the Folder1 would show me the S3file.txt which is added to the Folder1 from the S3 bucket. Running “dir” to list on the root of the file share would not show S3file2.

Hope above steps helps you understanding how to use RefreshCache.