feat(oo): file deep links, login check, replace-in (fresh upload)
- link: print Products/Files/DocEditor.aspx?fileid=… deep links (title+url) - lib: FileEditorURL/FolderURL helpers (+tests) - users check: verify credentials (userName vs email) via authentication.json - projects files replace-in FOLDER_ID FILE...: hard delete same stem|ext in a folder + fresh upload → single clean version (no version history)
This commit is contained in:
@@ -22,6 +22,7 @@ func projectFilesCmd() *cobra.Command {
|
||||
}
|
||||
cmd.AddCommand(prjFilesListCmd())
|
||||
cmd.AddCommand(prjFilesUploadCmd())
|
||||
cmd.AddCommand(prjFilesReplaceInCmd())
|
||||
cmd.AddCommand(prjFilesUpdateCmd())
|
||||
cmd.AddCommand(prjFilesDownloadCmd())
|
||||
cmd.AddCommand(prjFilesRenameCmd())
|
||||
@@ -150,6 +151,44 @@ Pass --no-replace to fail when the name is taken; --allow-duplicate to always cr
|
||||
return cmd
|
||||
}
|
||||
|
||||
func prjFilesReplaceInCmd() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "replace-in FOLDER_ID LOCAL_PATH [LOCAL_PATH...]",
|
||||
Short: "Replace same-named file(s) in a folder: hard delete + fresh upload (no version history)",
|
||||
Long: `Deletes any file in FOLDER_ID with the same stem|ext (hard delete — the CLI
|
||||
delete is permanent) and uploads the local file fresh. Unlike 'update' this
|
||||
leaves a single clean version, which matters when the file id is shared.
|
||||
|
||||
Note: file ids are server-assigned; a fresh upload gets a new id.`,
|
||||
Args: cobra.MinimumNArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
c, err := newOO(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
folderID := args[0]
|
||||
for _, p := range args[1:] {
|
||||
stem := onlyoffice.UploadStemFromLocal(p)
|
||||
ext := onlyoffice.UploadExtFromLocal(p)
|
||||
deleted, derr := c.DeleteFilesByDedupKey(cmd.Context(), folderID, stem, ext)
|
||||
if derr != nil {
|
||||
return derr
|
||||
}
|
||||
ent, uerr := c.UploadToFolder(cmd.Context(), folderID, p)
|
||||
if uerr != nil {
|
||||
return uerr
|
||||
}
|
||||
obj := fileEntryToMap(ent)
|
||||
if len(deleted) > 0 {
|
||||
obj["replaced_file_ids"] = deleted
|
||||
}
|
||||
printObject(obj)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func prjFilesUpdateCmd() *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "update FILE_ID LOCAL_PATH",
|
||||
|
||||
Reference in New Issue
Block a user