Skip to content

Commit

Permalink
Merge pull request #10 from avitalique/avitalique/rename-file
Browse files Browse the repository at this point in the history
add RenameFile method (#9)
  • Loading branch information
avitalique authored Sep 6, 2023
2 parents ba8ce0d + 96c4448 commit 72690aa
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export default function () {
});
check(response, { 'status was 200': response.status === 200 });
file.writeBytes(binaryFilepath, Array.from(new Uint8Array(response.body)));

// Rename file
file.renameFile(binaryFilepath, 'renamed-image.jpg')
}

```
Expand Down
3 changes: 3 additions & 0 deletions examples/sample-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,7 @@ export default function () {
});
check(response, { 'status was 200': response.status === 200 });
file.writeBytes(binaryFilepath, Array.from(new Uint8Array(response.body)));

// Rename file
file.renameFile(binaryFilepath, 'renamed-image.jpg')
}
9 changes: 9 additions & 0 deletions file.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ func (*FILE) ClearFile(path string) error {
return nil
}

// RenameFile renames file from oldPath to newPath
func (FILE) RenameFile(oldPath string, newPath string) error {
err := os.Rename(oldPath, newPath)
if err != nil {
return err
}
return nil
}

// DeleteFile deletes file
func (*FILE) DeleteFile(path string) error {
err := os.Remove(path)
Expand Down

0 comments on commit 72690aa

Please sign in to comment.