cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to know all about tools for creatives that work seamlessly with Dropbox, like Adobe? Well, check it out right here!

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Automatically Deleting Files After X Days - General Data Protection Regulation May 2018

Automatically Deleting Files After X Days - General Data Protection Regulation May 2018

outsidecoder
Helpful | Level 5

Hi there,

I'm using the Java SDK 3x (API v2) and I'm looking for pointers/code to automatically delete files that are X number of days old.  There is post on this forum which is doing this in python however not seen anything for Java.  I can't use any third party tools due to the context of my client's application.

 

With the European GDPR I feel this feature should be in built into the uploading process, that is defining a 'retention schedule' for all the files.  If this feature is going to be implemented will it be in time for when the Eurpoean GDPR  is active in May 2018?

 

Best regards and thanks for any assistance 🙂

12 Replies 12

Re: Automatically Deleting Files After X Days - General Data Protection Regulation May 2018

outsidecoder
Helpful | Level 5
Things are not looking good for business users in Europe. We should be able tell when a folder was modified* for GDPR.

https://www.dropboxforum.com/t5/API-support/Get-the-modified-date-for-a-folder-or-file/m-p/184489/hi...

*Ideally it should be the creation date, however that is probably a grey area for lawyers to argue over.

Re: Automatically Deleting Files After X Days - General Data Protection Regulation May 2018

outsidecoder
Helpful | Level 5

So created a quick bit of code to delete files older than X days but its very rough and hasn't been tested properly.  It doesn't get round the issue of dates of folders, nor does it get round the issue of not knowing the creation date.  Comments welcomed as there must be a better way than this?

 

   enum MODIFIED_DATE_TYPE {
        SERVER_MODIFIED_DATE, CLIENT_MODIFIED_DATE;
    }

    private long deleteFilesOlderThanXDays(long numDays, MODIFIED_DATE_TYPE TYPE) throws DbxException {
        //ALPHA - add protection against going above long.MAXIMUM
        long numberFilesDeleted = 0;
        ListFolderBuilder listFolderBuilder = client.files().listFolderBuilder("");
        ListFolderResult result = listFolderBuilder.withRecursive(true).start();

        while (!result.getHasMore()) {
            if (result != null) {
                for (Metadata entry : result.getEntries()) {
//                    System.out.println("Analysing: " + entry.getPathLower());
                    if (entry instanceof FileMetadata) {
                        Date dateOfFile;
                        switch (TYPE) {
                            case CLIENT_MODIFIED_DATE:
                                dateOfFile = ((FileMetadata) entry).getServerModified();
                                break;

                            case SERVER_MODIFIED_DATE:
                                dateOfFile = ((FileMetadata) entry).getClientModified();
                                break;
                            default:
                                throw new AssertionError();
                        }
                        //Check to see if the current file is too old
                        if (getDaysBetween(new Date(), dateOfFile) > numDays) {
                            this.deleteFile(entry.getPathLower());
                            numberFilesDeleted++;
                        }
                    }
                }
                if (!result.getHasMore()) {
                    return numberFilesDeleted;
                }
                try {
                    result = client.files().listFolderContinue(result.getCursor());
                } catch (DbxException e) {
                    //ALPHA - TIDY UP HERE.  CATCHING or THROWING??? - GDPR - Note what you're logging
                    //  log.info("Could NOT get listFolderContinue");
                }
            }
        }
        return numberFilesDeleted;
    }

Re: Automatically Deleting Files After X Days - General Data Protection Regulation May 2018

Greg-DB
Dropboxer

Thanks for the post! Dropbox doesn't offer a way to do this automatically via the API. I'm sending this along as feature requests for created and modified times for folders, as well as a native way to have Dropbox automatically delete files after a certain amount of time. I can't promise if/when these would be implemented though.

Re: Automatically Deleting Files After X Days - General Data Protection Regulation May 2018

LukFromTheSky
New member | Level 2

Hello Greg,

 

Was there any progress on that?

 

Thanks,

Luk

Re: Automatically Deleting Files After X Days - General Data Protection Regulation May 2018

Greg-DB
Dropboxer

@LukFromTheSky No, unfortunately I don't have an update on either of these feature requests.

Re: Automatically Deleting Files After X Days - General Data Protection Regulation May 2018

TateFF
Explorer | Level 3

I'm a little shocked there isn't a way to do this.  Has there been any progress on implementing this functionality?

Re: Automatically Deleting Files After X Days - General Data Protection Regulation May 2018

Greg-DB
Dropboxer

@TateFF No, unfortunately I don't have any news on this request.

Re: Automatically Deleting Files After X Days - General Data Protection Regulation May 2018

mpk2
New member | Level 2

Is there a reason this feature isn't being built?

Re: Automatically Deleting Files After X Days - General Data Protection Regulation May 2018

Greg-DB
Dropboxer

@mpk2 I can't speak to why Dropbox may have decided to work on any particular feature request or not. This feature request is still open and I'll follow up here with any updates if/when I have anything to share. I don't have any news on this right now though.

Poll
Do you work or study in the creative industry? If so, which area?
If you use Adobe, don't forget to check out our latest integrations update here.
Who's talking

Top contributors to this post

  • User avatar
    qopera New member | Level 2
  • User avatar
    Greg-DB Dropboxer
  • User avatar
    ABC15 New member | Level 2
  • User avatar
    mpk2 New member | Level 2
What do Dropbox user levels mean?
Need more support?