Rick Goodrow
07/31/2024, 6:26 PMN/file
module. If you use Nfile.copy()
method, you can include the conflictResolution
option to dictate what happens when it tries to copy a file to a folder with the same name. However if you use the Nfile.create()
method, there is no conflictResolution
option, and appears to ignore it if provided. Based on my testing, Nfile.create()
will overwrite an existing file with no warnings if the name is the same. Writing a suitelet that has file uploads, and while I was planning to upload directly to a folder with that conflict resolution, it appears that will just overwrite things, and the only safe way is to
1. Nfile.create()
the file in a temp folder
2. write contents and Nfile.save()
3. copy file to the actual target folder with the conflictResolution
option set
4. delete file out of temp folder
unless someone has a better way of handling duplicate name file uploads into the same folderAnthony OConnor
07/31/2024, 6:29 PMAnthony OConnor
07/31/2024, 6:31 PMfilename = `${filename}-${new Date.valueOf()}`
Anthony OConnor
07/31/2024, 6:31 PMAnthony OConnor
07/31/2024, 6:38 PMRick Goodrow
07/31/2024, 6:39 PMRick Goodrow
07/31/2024, 6:39 PMAnthony OConnor
07/31/2024, 6:46 PMRick Goodrow
07/31/2024, 7:25 PMAnthony OConnor
07/31/2024, 7:27 PMShawn Talbert
07/31/2024, 8:07 PMupsert
(in that, it either creates or updates - entirely - the existing file). There are no 'update' functions I'm aware of for arbitrary file types. I think there's one for delimited text only?erictgrubaugh
07/31/2024, 11:56 PMcreate()
method? I'm going to need to test that. I frequently see people asking how to update file contents.Rick Goodrow
08/01/2024, 2:01 AMNfile.create()
method, and specify the name
option that is the same as another file within the same folder, it will overwrite the contents, description, even overwrite the file type, but it will not generate a new Internal ID for that file, which just seems wild to me.Rick Goodrow
08/01/2024, 2:01 AMNElliott
08/01/2024, 8:24 AMShawn Talbert
08/01/2024, 4:17 PM