1
0
mirror of https://github.com/owncloud/ocis.git synced 2025-04-18 23:44:07 +03:00

Fix pdf form creation for Onlyoffice

This commit is contained in:
Roman Perekhod 2025-03-26 12:29:54 +01:00
parent 7146fefb34
commit c9e0547dce
7 changed files with 50 additions and 21 deletions

View File

@ -0,0 +1,7 @@
Bugfix: Fix pdf form creation
Fix pdf form creation for Onlyoffice.
Adjust the file extension for Form to be PDF instead of DOCXF
https://github.com/owncloud/ocis/pull/11163
https://github.com/owncloud/ocis/issues/11164

View File

@ -1,12 +1,5 @@
app_registry:
mimetypes:
- mime_type: application/pdf
extension: pdf
name: PDF
description: PDF document
icon: ''
default_app: ''
allow_creation: false
- mime_type: application/vnd.oasis.opendocument.text
extension: odt
name: OpenDocument
@ -41,7 +34,7 @@ app_registry:
description: Form Document
icon: ''
default_app: OnlyOffice
allow_creation: true
allow_creation: false
- mime_type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
extension: xlsx
name: Microsoft Excel
@ -56,6 +49,13 @@ app_registry:
icon: ''
default_app: OnlyOffice
allow_creation: true
- mime_type: application/pdf
extension: pdf
name: PDF form
description: PDF form document
icon: ''
default_app: OnlyOffice
allow_creation: true
- mime_type: application/vnd.jupyter
extension: ipynb
name: Jupyter Notebook

View File

@ -67,5 +67,4 @@
]
}
}
}

View File

@ -37,12 +37,6 @@ func DefaultConfig() *config.Config {
func defaultMimeTypeConfig() []config.MimeTypeConfig {
return []config.MimeTypeConfig{
{
MimeType: "application/pdf",
Extension: "pdf",
Name: "PDF",
Description: "PDF document",
},
{
MimeType: "application/vnd.oasis.opendocument.text",
Extension: "odt",
@ -72,11 +66,10 @@ func defaultMimeTypeConfig() []config.MimeTypeConfig {
AllowCreation: true,
},
{
MimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.form",
Extension: "docxf",
Name: "Form Document",
Description: "Form Document",
AllowCreation: true,
MimeType: "application/vnd.openxmlformats-officedocument.wordprocessingml.form",
Extension: "docxf",
Name: "Form Document",
Description: "Form Document",
},
{
MimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
@ -92,6 +85,13 @@ func defaultMimeTypeConfig() []config.MimeTypeConfig {
Description: "Microsoft PowerPoint document",
AllowCreation: true,
},
{
MimeType: "application/pdf",
Extension: "pdf",
Name: "PDF form",
Description: "PDF form document",
AllowCreation: true,
},
{
MimeType: "application/vnd.jupyter",
Extension: "ipynb",

View File

@ -1243,9 +1243,20 @@ func (f *FileConnector) CheckFileInfo(ctx context.Context) (*ConnectorResponse,
}
}
// fileinfo map
var size interface{}
size = int64(statRes.GetInfo().GetSize())
// OnlyOffice requires a 0 size of files for "pdf" files, for extensions "docx", "xlsx", "pptx" it is optional
// For other extensions like "ods", "odt", "odp" the 0 size should be omitted
if strings.ToLower(f.cfg.App.Product) == "onlyoffice" && statRes.GetInfo().GetSize() == 0 {
ext := strings.ToLower(path.Ext(statRes.GetInfo().GetPath()))
if ext != ".pdf" {
size = nil
}
}
infoMap := map[string]interface{}{
fileinfo.KeyOwnerID: hexEncodedOwnerId,
fileinfo.KeySize: int64(statRes.GetInfo().GetSize()),
fileinfo.KeySize: size,
fileinfo.KeyVersion: getVersion(statRes.GetInfo().GetMtime()),
fileinfo.KeyBaseFileName: path.Base(statRes.GetInfo().GetPath()),
fileinfo.KeyBreadcrumbDocName: path.Base(statRes.GetInfo().GetPath()),

View File

@ -18,6 +18,7 @@ import (
typesv1beta1 "github.com/cs3org/go-cs3apis/cs3/types/v1beta1"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/owncloud/ocis/v2/ocis-pkg/conversions"
"github.com/owncloud/ocis/v2/ocis-pkg/shared"
collabmocks "github.com/owncloud/ocis/v2/services/collaboration/mocks"
"github.com/owncloud/ocis/v2/services/collaboration/pkg/config"
@ -1876,6 +1877,7 @@ var _ = Describe("FileConnector", func() {
expectedFileInfo := &fileinfo.OnlyOffice{
Version: "v162738490",
Size: conversions.ToPointer(int64(998877)),
BaseFileName: "test.txt",
BreadcrumbDocName: "test.txt",
BreadcrumbFolderName: "/path/to",

View File

@ -1,5 +1,9 @@
package fileinfo
import (
"github.com/owncloud/ocis/v2/ocis-pkg/conversions"
)
// OnlyOffice fileInfo properties
//
// OnlyOffice WOPI check file info specification:
@ -13,6 +17,8 @@ type OnlyOffice struct {
BaseFileName string `json:"BaseFileName,omitempty"`
// copied from MS WOPI
Version string `json:"Version,omitempty"`
// The size of the file in bytes, expressed as a long, a 64-bit signed integer.
Size *int64 `json:"Size,omitempty"`
//
// Breadcrumb properties
@ -137,6 +143,10 @@ func (oinfo *OnlyOffice) SetProperties(props map[string]interface{}) {
oinfo.BaseFileName = value.(string)
case KeyVersion:
oinfo.Version = value.(string)
case KeySize:
if value != nil {
oinfo.Size = conversions.ToPointer(value.(int64))
}
case KeyBreadcrumbBrandName:
oinfo.BreadcrumbBrandName = value.(string)