Desktop version

Main > Forum > 1C:Enterprise Platform > Studying 1C:Enterprise platform > How to store a file in the database?

Forum

Search UsersRules
How to store a file in the database?
#1
Active user
Points:: 0
Joined:: Sep 27, 2011

How to store a file in the database? I want attach photos to items.

Profile
#2
Just came
Points:: 7
Joined:: Mar 15, 2012

You should create catalog and attribute in it with type ValueStorage.

Profile
#3
Active user
Points:: 0
Joined:: Sep 27, 2011

OK, I've did so but I can not place attribute of this type on a form. It is written in Type column: Not available in form data...

Profile
#4
Guest
Points::
Joined::

First you need to use PutFile function to send a file from client to server and pass a string with storage address to GetFile function at server to retrieve it from temp storage.
Next you need to pack it into ValueStorage type attribute and write a container object.

Code
&AtClient
Procedure LoadFile(Command)
   StorageName = "";
   FileName = Object.FileName;
   PutFile(StorageName, FileName, FileName, True, UUID);
   LoadFileServer(StorageName);
EndProcedure


&AtServer
Procedure LoadFileServer(StorageName)
   ObjectValue = FormDataToValue(Object, Type("CatalogObject.StoredFiles"));
   ObjectValue.Data = New ValueStorage(GetFromTempStorage(StorageName));
   ObjectValue.Write();
   ValueToFormData(ObjectValue, Object);
EndProcedure

Profile
Subscribe
Users browsing this topic (guests: 1, registered: 0, hidden: 0)



© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.