BBjFileSave

Description

In BBj 25.03 and higher, the BBjFileSave object is equivalent to the FILESAVE() Function - Create File Save Dialog.

Creation

BBjAPI > BBjFileSave

The BBjFileSave object is created through the following BBjAPI method:

Return Value Method
BBjFileSave filesave()

Methods of BBjFileSave

Return Value Method
BBjFileSave ext(String ext)
BBjFileSave filters(String filters)
BBjFileSave mode(int mode)
BBjFileSave modes(String modes)
BBjFileSave name(String name)
BBjFileSave path(String path)
String show()
BBjFileSave title(String title)

Constants

Value BBjFileSave Constant Action
0 FILESAVE_SELECT_FILE (default) Only files may be selected
1 FILESAVE_SELECT_DIRECTORY Only directories may be selected
2 FILESAVE_SELECT_FILE_OR_DIRECTORY Files or directories may be selected

Example

rem ' bbjapi-clientfile.txt
precision 6
tc! = bbjapi().getThinClient()
fs! = tc!.getClientFileSystem()
filter$ = ""
filter$ = filter$ + "Text Files (*.txt)"+$0a$+"*.txt"+$0a$
filter$ = filter$ + "HTML Files (*.htm;*.html)"+$0a$+"*.htm;*.html"+$0a$
filter$ = filter$ + "Image Files (*.png;*.jpg;*.jpeg;*.bmp;*.gif)"+$0a$+"*.png;*.jpg;*.jpeg;*.bmp;*.gif"+$0a$
filter$ = filter$ + "All Files (*.*)"+$0a$+"*.*"+$0a$
i = bbjapi().msgbox().message("Test client fileopen + copy file from client to server").modes("theme=info").show()
clientfile$ = bbjapi().fileopen().title("Pick a client file").filters(filter$).modes("client,theme=primary").show()
i = bbjapi().msgbox().message(clientfile$).title("Selected client file").modes("theme=info").show()
if pos("::"=clientfile$) then goto eoj
cf! = fs!.getClientFile(clientfile$)
i = bbjapi().msgbox().message("Copy "+clientfile$+" to the server").modes("theme=primary").show()
t = tim
serverfile$ = cf!.copyFromClient()
t = tim - t
t = t * 3600
serverfile = unt
open (serverfile)serverfile$
serverfile$ = fid(serverfile)(9)
bytes = dec(fin(serverfile)(1,4))
close (serverfile)
i = bbjapi().msgbox().message("Copied client file "+clientfile$+" to server file "+serverfile$+" ("+str(bytes)+" bytes; "+str(t)+" seconds)").title("Copied from client to server").modes("theme=primary").show()
i = bbjapi().msgbox().message("Test server fileopen + copy file from server to client").modes("theme=info").show()
serverfile$ = bbjapi().fileopen().title("Pick a server file").filters(filter$).modes("theme=primary,sort=+name").show()
i = bbjapi().msgbox().message(serverfile$).title("Selected server file").modes("theme=info").show()
if pos("::"=serverfile$) then goto eoj
clientfile! = new java.io.File(serverfile$)
clientfile$ = clientfile!.getName()
clientfile$ = bbjapi().filesave().title("Save to client").name(clientfile$).filters(filter$).modes("client,theme=primary").show()
if pos("::"=clientfile$) then goto eoj
i = bbjapi().msgbox().message("Copy server file "+serverfile$+" to client file "+clientfile$).modes("theme=primary").show()
cf! = fs!.getClientFile(clientfile$)
rem ' To immediately delete the ClientFile from the server-side cache after copying it to the browser client, add this to BBj.properties:
rem ' com.basis.bbj.web.file.FileDownloadServlet.autoDelete=true
cf!.copyToClient(serverfile$)
i = bbjapi().msgbox().message("Copied server file "+serverfile$+" to client file "+clientfile$).title("Copied from server to client").modes("theme=success").show()
eoj:
release

See Also

BBjAPI

BBjAPI - Filesave

FILESAVE() Function - Create File Save Dialog

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.