cancel
Showing results for 
Search instead for 
Did you mean: 

Invalid file name error while uploading arabic files

sambit_h
Champ in-the-making
Champ in-the-making
Hi
I am useing alfresco web services to upload documents from my application.
It works fine as long as i am uploading any file which is in english.
When i am trying to upload Arabic file name and file content it gives me error as invalid file name.
how ever a 0 KB file with name ?????.pdf gets created in the spece.
Can anyone help me on this?

THanks in advance
6 REPLIES 6

jcustovic
Champ in-the-making
Champ in-the-making
Try encoding your file name with
yourFilename = ISO9075.encode(yourFilename);

sambit_h
Champ in-the-making
Champ in-the-making
Thanks.
But when i am encoding the file name as suggested by you its still not working.
It creates a 0 KB file with name as ????_x0020_????.pdf.
This is the code i am using

            RepositoryServiceSoapBindingStub repositoryService = WebServiceFactory.getRepositoryService();       
           

            ParentReference parentReference = new ParentReference(getStoreRef(), null, "/app:company_home/cm:hammid_x0020_hani", Constants.ASSOC_CONTAINS, Constants.ASSOC_CONTAINS);           
            NamedValue[] properties = new NamedValue[]{Utils.createNamedValue(Constants.PROP_NAME, ISO9075.encode(documentVO.getDocFileName()))};
            CMLCreate create = new CMLCreate("id1", parentReference, null, null, null, Constants.TYPE_CONTENT, properties);       
            CMLAddAspect addAspect = new CMLAddAspect(Constants.ASPECT_VERSIONABLE, null, null, "id1");
            CML cml = new CML();
            cml.setCreate(new CMLCreate[]{create});
            cml.setAddAspect(new CMLAddAspect[]{addAspect});
           
            // Execute the update
            UpdateResult[] updateResults = repositoryService.update(cml);
            
            Reference docRef = updateResults[0].getDestination();

jcustovic
Champ in-the-making
Champ in-the-making
Your code is good. For the filename problem you should check to see if your database is set to UTF8, because arabic letters are working fine for me. And to actually upload the document you can use

ContentFormat format = new ContentFormat(mimeType, encoding);
getContentService().write(nodeReference, Constants.PROP_CONTENT, contentInBytes, format);

sambit_h
Champ in-the-making
Champ in-the-making
Thanks for your reply.
I am using the below command in mySQL to set the database charset to utf8
set character_set_database=utf8;
set session character_set_server=utf8;
set global character_set_server=utf8;
set names utf8;

But once i restart the server the charset automatically changes to latin1.
Thats the reason i think alfresco is storing ????? in the file name.
Any idea how to change the MySQL data base charset to utf8

jcustovic
Champ in-the-making
Champ in-the-making
You can edit my.ini file and set:

[mysqld]
default-character-set=utf8

There are other options to configure my.ini file so you can find them if you'll need them…

sambit_h
Champ in-the-making
Champ in-the-making
Thanks,
This works fine after changing the MySQL database charset to utf8.
I can upload arabic alnguage documents/titles now.

Thanks for your support.