Hi, I did what you've told me ... i think it's working but i can't find a way to open it, I'll show you my code.
here the user can choose the pdf from a browser
Code
&AtClient
Procedure Command1(Command)
Dialog = New FileDialog(FileDialogMode.Open);
If Dialog.Choose() Then
pdf= ss(Dialog.FullFileName);
EndIf;
EndProcedure
&AtServer
function ss(dialog)
pdf= new ValueStorage (dialog,New Deflation(9));
Return pdf
EndFunction
I added this to the previous code as you said ...as a result a new window is opened and asked me to <open> <save> <cancel> the file ... when i press open nothing is happening
Code
&AtServer
Procedure OnCreateAtServer(Cancel, StandardProcessing)
ObjectValue = FormDataToValue(Object, Type("DocumentObject.Document1"));
StorageName = PutToTempStorage(ObjectValue.storage.Get(), UUID);
EndProcedure
&AtClient
Procedure pdfview(Command)
Message(StorageName);
If Not IsBlankString(StorageName) Then
GetFile(StorageName,"1C Ebook", True);
EndIf;
EndProcedure
I guess that you are uploading file and right after that trying to see it. As storage name is updated in OnCreateAtServer handler, the file that you have uploaded will not be accessible until you will open your document form again. So you need to update storage name after uploading file:
Also please note that if you put file to temp storage when form is created, you make form opening slower, but on the other side your PDF file will be opened faster when a user will execute command. You could also move UpdateStorageName() to PDFView() instead of OnCreateAtServer():
Code
&AtClient
Procedure PDFView(Command)
If Not IsBlankString(Object.StorageName) Then
UpdateStorageName()
GetFile(Object.StorageName,Object.Description, true);
EndIf;
EndProcedure
The variant depends on what is more importand. I suppose that in your case this variant would be more efficient.
I had a very similar task, and a technical specialist of 1C company helped me. I don't know if he likes I mention his name. But I believe he doesn't mind if I share this information with you.
At first we load a file
Code
&AtClient
Procedure LoadFile1(Command)
StorageName1 = "";
FileName = Object.FileName;
If PutFile(StorageName1, FileName, FileName, True, UUID) Then
LoadFileServer1(StorageName1);
EndIf;
EndProcedure
Here is "If PutFile(...True) then" important, because a user can just close this form and don't attach a file.
Then we save it into the Storage. In my case it is an attribute Storage1 (I have 4 of them)
&AtClient
Procedure OpenFile1(Command)
TempFileName = GetTempFileName("pdf"); // I need only pdf-files
StorageURL = GetURL(Object.Ref, "Storage1");
GetFile(StorageURL, TempFileName, False);
RunApp(TempFileName);
EndProcedure
StorageURL is important, because we can not directly access Object.Storage1. GetFile(...) saves the file onto the disc and RunApp(...) is a function to open this file.