Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting returns true, but file is not deleted #119

Open
ghost opened this issue Jul 19, 2016 · 6 comments
Open

Deleting returns true, but file is not deleted #119

ghost opened this issue Jul 19, 2016 · 6 comments

Comments

@ghost
Copy link

ghost commented Jul 19, 2016

Hi Lepozepo. Firstly i want to say thank you for you awesome package

I successfully upload files using your package and store result in mongo db collection. Like this:

    constructor(name, filesPath) {
        this.filesPath = filesPath;
        this.collection = new Mongo.Collection(`filemanager.${name}`);
    }

    insert(files, callback) {
        S3.upload({files, path: this.filesPath},
            (error, result) => {
                if (!error) {
                    const id = this.collection.insert(result);
                    callback(error, id);
                }
                else {
                    callback(error, null);
                }
            }
        );
    }

Then i use relative url from the mongo document to delete the file.

    remove(id) {
        const file = this.collection.findOne(id);
        if (file) {
            S3.delete(file.relative_url, (error, result) => {
                if (!error) {
                    this.collection.remove(id);
                }
            })
        }
    }

As a result i always receive true in response, but file is not deleted from s3 service.
Could you hint me where i'm wrong please

@Lepozepo
Copy link
Owner

Hmm, that looks like it should work, I've been receiving issues with the delete function lately, I'll have a second look for sure as soon as I can but if you could fork and PR if you find the issue that would be great ^_^

@jantrienes
Copy link

I can confirm that this issue occurs. My upload works just fine as well. However, the delete callback returns true although the file is still present at the S3.

My setup has as the region eu-central-1.

@ziks21 did you find a solution?

@jantrienes
Copy link

I ended up using the AWS sdk method for this:

S3.aws.deleteObject({
  Bucket: 'bucket',
  Key: 'objectKey'
}, function(err, data) {
  if (err) {
    console.log(err);
  }
  console.log(data); 
});

The method deleted the object properly. However, it is important to notice, that the key which is passed as parameter, is relative to the root of the bucket. This differs from the way S3.delete(path,callback) works.

@THPubs
Copy link

THPubs commented Nov 17, 2016

Hi @Lepozepo any updates on this issue? I still can't delete a file.

@steven-tib
Copy link

Hi @Lepozepo, I cannot delete a file with S3.delete either.
I will give a try at @jantrienes method in the meantime.

@penguinoz
Copy link

Hi @Lepozepo, I have same issue. The file is not deleted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants