Error when I try to delete a file

dreamobjects

#1

Hi guys, I am trying to delete files using the API but I get the following error : The AWS Access Key Id you provided does not exist in our records

I am using Ruby On Rails

I have this in my gemfile : gem 'aws-sdk', '< 2.0'

and I created a aws.rb in initializer folder to have global variable in my app with the following :

[code]AWS.config(access_key_id: ‘…key id…’, secret_access_key: ‘…secret_key…’)

S3_BUCKET = AWS::S3.new.buckets[‘my_bucket’][/code]

When I upload a file the path for that file is like the following :

my_backet/uploads/391cd178-a64a-4fda-83b6-210430c34a0c/file.png

and finally here the method to delete the file :

[code]def delete_file

  key = '391cd178-a64a-4fda-83b6-210430c34a0c/file.png'

  S3_BUCKET.objects[key].delete

end[/code]

and the error is :

AWS::S3::Errors::InvalidAccessKeyId in ImagesController#delete_file The AWS Access Key Id you provided does not exist in our records.

any help please ?


#2

Sorry to hear of the issues. It could be an issue of the aws-sdk trying to use signature version v4, which is not fully supported in DreamObjects yet. In the meantime, can you try in your config section to define “signature_version” with “v2” or “” and see if that changes the behavior? I believe the code mentions this param but it seems to be hidden to assume v4.

Hope that helps!


#3

I am using the version 1 of aws-sdk which use signature version 2 so I don’t think this is where the issue comes from !!

see the answer here : https://github.com/aws/aws-sdk-ruby/issues/921 (the version 1 of aws-sdk use signature v2)


#4

Looking at the error, I think it’s actually trying to connect to AWS rather than DreamObjects. You’ll need to specify the endpoint in the config:

Updated with thanks to mody49


#5

Hi justinlund,

I came to the same conclusion as you before reading your answer and I was coming to ask you about that exactly haha I noticed the same thing using another gem called ‘aws-s3’ which the examples in the documentation use too, so when I provide :

it works, but if I remove it then I get the same error as the error I get using ‘aws-sdk’ gem, so it was abvious that I need to provide the server name or something like that :slight_smile:

just a tiny correction to your snippet, it should be :

just add ‘s3_’ to endpoint, otherwise it won’t work!

Thank you so so much, I am new here and I start to love dreamhost for the awesome support :smiley:
[hr]
oh another question as I am excited to start using that : should I backup the uploaded files of my users somewhere else or dreamobjects provide a kind of integrated backup ? I just wanna to be sure that my users files stay safe


#6

You should always back up your files outside of DreamHost. Should anything happen (disaster, accidental erase, deleted account), you’ll have a backup.


#7

Backups are important, and it is great you are thinking about this. DreamHost has its services spread around the United States, with datacenters located in Portland Oregon, Ashburn Virginia, and DreamObjects in Irvine, California to this date. The cloud systems like DreamObjects and DreamCompute are also completely separate systems, even if residing in the same datacenter as other DreamHost products. We are confident in the stability of these cloud systems for backup and using them is recommended, however for extremely sensitive and important data another offsite backup provider may be recommended by your system administrators for the absolute worst of worst cases. When we have multiple regions for DreamObjects in the future, that may be distributed enough depending on your needs and budget as well.

Thanks for the feedback and code samples to help other customers who may have the same issue in the future.


#8

What sdayman said: even if DreamObjects has internal redudancy and failover, your data is still subject to all sorts of other kind of dangers. They could be deleted accidentally, overwritten, vandalized etc… if you care for your data, keep copies.


#9

Thank you for your advice, do you recommend any backup tool or script with dreamobjects? I am really new to this stuff and I have no idea what I should do, this is the first time I am playing with it! I am using ruby on rails for my server developpement! Thanks!
[hr]

Thank you, is there any good script/library used to do backups with dreamobjects?
[hr]

Thank you, do you advice to use any script/library to do backups ? so far I just implemented file upload and file delete, I will appreciate if someone provide some code for doing backup…


#10

There are a lot of tools available for backups to DreamObjects.

If you want one that does full and incremental backups for you, while encrypting the data in the process, there is duplicity:

If you have your own scripts to run on occasion, there are command line tools like:

s3cmd - https://help.dreamhost.com/hc/en-us/articles/215916627-How-to-use-S3cmd-with-DreamObjects
boto-rsync - https://help.dreamhost.com/hc/en-us/articles/217473218-How-to-use-boto-rsync-with-DreamObjects

or if you want a graphical backup program for Windows or Mac, there are some paid options like:

CloudBerry Backup (Windows) - https://help.dreamhost.com/hc/en-us/articles/215253458-How-to-Use-CloudBerry-Backup-with-DreamObjects
Arq (Windows and Mac) - https://help.dreamhost.com/hc/en-us/articles/215916587-How-to-Use-Arq-with-DreamObjects

and others. Most software designed to use the S3 protocol will work.