x11 Posted October 26, 2021 Share Posted October 26, 2021 Код простой UniSession.SendFile(UniServerModule.LogFullPath + cbLogFiles.Text);// cbLogFiles содержит список лог-файлов в папке log получаю ошибку в консоли браузера ext-all.js:20 GET http://localhost:8077/cache/programmaweb_exe/3sLWWMZKnZ10936FFA4/$$$/A2021-10-22.log 401 (Unauthorized) Quote Link to comment Share on other sites More sharing options...
x11 Posted October 27, 2021 Author Share Posted October 27, 2021 up Quote Link to comment Share on other sites More sharing options...
zilav Posted October 27, 2021 Share Posted October 27, 2021 А в чем логика, файлы у тебя в папке Logs, а качать ты их почему-то собрался из кэша судя по URI Quote Link to comment Share on other sites More sharing options...
x11 Posted October 27, 2021 Author Share Posted October 27, 2021 обрати внимание на код где там кэш? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 27, 2021 Share Posted October 27, 2021 23 hours ago, x11 said: UniSession.SendFile(UniServerModule.LogFullPath + cbLogFiles.Text);// cbLogFiles содержит список лог-файлов в папке log Logger.FullPath Logger.FullName ? Quote Link to comment Share on other sites More sharing options...
x11 Posted October 27, 2021 Author Share Posted October 27, 2021 UniServerModule.LogFullPath в отладчике на бэкэнде выдает правильный путь к папке log, плюс в выпадающий список загружается список log-файлов. Проблема при попытке скачать. Quote Link to comment Share on other sites More sharing options...
x11 Posted October 27, 2021 Author Share Posted October 27, 2021 идея такова, чтобы в комбобокс загрузить список доступных лог-файлов и по кнопке Скачать пользователь или админ мог загрузить выбранный файл на свой ПК из браузера Quote Link to comment Share on other sites More sharing options...
x11 Posted October 27, 2021 Author Share Posted October 27, 2021 Я так полагаю, что лог-файл нужно куда-то переложить сперва, чтобы были права на доступ к этому файлу, например в папку /Files, а уже потом только пытаться скачать. Quote Link to comment Share on other sites More sharing options...
x11 Posted October 27, 2021 Author Share Posted October 27, 2021 Просто uniGUI не дает функции SendFile() доступ к папке UniServerModule.LogFullPath. Я прав? Quote Link to comment Share on other sites More sharing options...
zilav Posted October 27, 2021 Share Posted October 27, 2021 Логично, у тебя есть полный доступ к папке cache, вот и переложи нужный лог-файл туда, после чего скачивай его уже оттуда я вообще не вижу папки logs в твоем URI, он лезет в папку cache, но есть ли у тебя там этот файл я хз http://localhost:8077/cache/programmaweb_exe/3sLWWMZKnZ10936FFA4/$$$/A2021-10-22.log Quote Link to comment Share on other sites More sharing options...
x11 Posted October 28, 2021 Author Share Posted October 28, 2021 11 hours ago, zilav said: я вообще не вижу папки logs в твоем URI так этот путь строю (создаю) не я... я использую готовую переменную uniGUI. Использую не совсем правильно в данном случае, как я понял. Quote Link to comment Share on other sites More sharing options...
x11 Posted October 28, 2021 Author Share Posted October 28, 2021 @Sherzod подскажите, почему переменная "UniServerModule.CacheFolderPath" ссылается на папку, откуда запущена программа, а не на папку с кэшэм? В документации написано: Quote CacheFolderPath - This property returns the current physical path of cache folder. Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 28, 2021 Share Posted October 28, 2021 9 minutes ago, x11 said: подскажите, почему переменная "UniServerModule.CacheFolderPath" ссылается на папку, откуда запущена программа, а не на папку с кэшэм? CacheFolder A uniGUI server needs a folder to create temporary files. Normally, it is a folder named Cache created under the same folder your module exists. You can change this default location by assigning a different path to the CacheFolder parameter. Under IIS, you must be sure that your application has enough credentials for a full access to CacheFolder. If you want to change these properties at runtime, do it on the event handler OnBeforeInit of UniServerModule. http://unigui.com/doc/online_help/adjusting_paths.htm Quote Link to comment Share on other sites More sharing options...
x11 Posted October 28, 2021 Author Share Posted October 28, 2021 При попытке использовать переменную "UniServerModule.GlobalCachePath" тоже получаю ошибку Quote Failed to load resource: the server responded with a status of 401 (Unauthorized) ext-all.js:20 GET http://localhost:8077/cache/programaweb_exe/cWjPLlQ6Vv10939B781/$$$/A2021-10-28.log 401 (Unauthorized) Quote Link to comment Share on other sites More sharing options...
x11 Posted October 28, 2021 Author Share Posted October 28, 2021 1 minute ago, Sherzod said: If you want to change these properties at runtime, do it on the event handler OnBeforeInit of UniServerModule. Мне ничего меня не надо. Я уже писал: 18 hours ago, x11 said: идея такова, чтобы в комбобокс загрузить список доступных лог-файлов и по кнопке Скачать пользователь или админ мог загрузить выбранный файл на свой ПК из браузера т.е. вопрос: правильно как сделать, куда перед скачиванием скопировать лог-файл? Quote Link to comment Share on other sites More sharing options...
x11 Posted October 28, 2021 Author Share Posted October 28, 2021 procedure TfrdAppSettings.UniButton1Click(Sender: TObject); begin if not FileExists(UniServerModule.LogFullPath + cbLogFiles.Text) then begin ЬнErrorMessage(constErrFileNotExists, nil, UniServerModule.LogFullPath + cbLogFiles.Text); exit; end; // скопировать в папку /Files TFile.Copy(UniServerModule.LogFullPath + cbLogFiles.Text, UniServerModule.FilesFolderPath + cbLogFiles.Text, True); //скачать UniSession.SendFile(UniServerModule.FilesFolderPath + cbLogFiles.Text); end; в папке /files лог-файл появляется (картинка 2), потом, при скачивании - ошибка (картинка 1) Что я делаю не так? Quote Link to comment Share on other sites More sharing options...
estrify Posted October 28, 2021 Share Posted October 28, 2021 Hi, I think it is related with file extension... Rename the file to .txt and you will see how UniGUI will serve it. 1 Quote Link to comment Share on other sites More sharing options...
x11 Posted October 28, 2021 Author Share Posted October 28, 2021 Yes! Super! Thanks! I renamed the expansion and this solved my problem. Quote Link to comment Share on other sites More sharing options...
x11 Posted October 28, 2021 Author Share Posted October 28, 2021 @Sherzod подскажите пожалуйста, как понять, какие расширения запрещены или разрешены? Где храниться этот список запрещенных или разрешенных расширений файлов? Как можно менять этот список? Спасибо. Quote Link to comment Share on other sites More sharing options...
estrify Posted October 28, 2021 Share Posted October 28, 2021 10 minutes ago, x11 said: Yes! Super! Thanks! I renamed the expansion and this solved my problem. You're welcome... Be careful with UniGUI's access control to files. Don't assume anything: i.e. if you put the file into your bin directory, you can still access it with https://localhost/test.txt or https://localhost/files/../test.txt 😱 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 28, 2021 Share Posted October 28, 2021 16 minutes ago, x11 said: какие расширения разрешены? .nml=animation/narrative .aac=audio/mp4 .aif=audio/x-aiff .aifc=audio/x-aiff .aiff=audio/x-aiff .au=audio/basic .gsm=audio/x-gsm .kar=audio/midi .m3u=audio/mpegurl .m4a=audio/x-mpg .mid=audio/midi .midi=audio/midi .mpega=audio/x-mpg .mp2=audio/x-mpg .mp3=audio/x-mpg .mpga=audio/x-mpg .pls=audio/x-scpls .qcp=audio/vnd.qcelp .ra=audio/x-realaudio .ram=audio/x-pn-realaudio .rm=audio/x-pn-realaudio .sd2=audio/x-sd2 .sid=audio/prs.sid .snd=audio/basic .wav=audio/x-wav .wax=audio/x-ms-wax .wma=audio/x-ms-wma .mjf=audio/x-vnd.audioexplosion.mjuicemediafile .art=image/x-jg .bmp=image/bmp .cdr=image/x-coreldraw .cdt=image/x-coreldrawtemplate .cpt=image/x-corelphotopaint .djv=image/vnd.djvu .djvu=image/vnd.djvu .gif=image/gif .ief=image/ief .ico=image/x-icon .jng=image/x-jng .jpg=image/jpeg .jpeg=image/jpeg .jpe=image/jpeg .pat=image/x-coreldrawpattern .pcx=image/pcx .pbm=image/x-portable-bitmap .pgm=image/x-portable-graymap .pict=image/x-pict .png=image/x-png .pnm=image/x-portable-anymap .pntg=image/x-macpaint .ppm=image/x-portable-pixmap .psd=image/x-psd .qtif=image/x-quicktime .ras=image/x-cmu-raster .rf=image/vnd.rn-realflash .rgb=image/x-rgb .rp=image/vnd.rn-realpix .sgi=image/x-sgi .svg=image/svg+xml .svgz=image/svg+xml .targa=image/x-targa .tif=image/x-tiff .wbmp=image/vnd.wap.wbmp .webp=image/webp .xbm=image/xbm .xpm=image/x-xpixmap .xwd=image/x-xwindowdump .323=text/h323 .xml=text/xml .uls=text/iuls .txt=text/plain .rtx=text/richtext .wsc=text/scriptlet .rt=text/vnd.rn-realtext .htt=text/webviewhtml .htc=text/x-component .vcf=text/x-vcard .asf=video/x-ms-asf .asx=video/x-ms-asf .avi=video/x-msvideo .dl=video/dl .dv=video/dv .flc=video/flc .fli=video/fli .gl=video/gl .lsf=video/x-la-asf .lsx=video/x-la-asf .mng=video/x-mng .mp4=video/mpeg .mpeg=video/x-mpeg2a .mpa=video/mpeg .mpe=video/mpeg .mpg=video/mpeg .ogv=video/ogg .moov=video/quicktime .mov=video/quicktime .mxu=video/vnd.mpegurl .qt=video/quicktime .qtc=video/x-qtc .rv=video/vnd.rn-realvideo .ivf=video/x-ivf .webm=video/webm .wm=video/x-ms-wm .wmp=video/x-ms-wmp .wmv=video/x-ms-wmv .wmx=video/x-ms-wmx .wvx=video/x-ms-wvx .rms=video/vnd.rn-realvideo-secure .movie=video/x-sgi-movie .7z=application/x-7z-compressed .a=application/x-archive .aab=application/x-authorware-bin .aam=application/x-authorware-map .aas=application/x-authorware-seg .abw=application/x-abiword .ace=application/x-ace-compressed .ai=application/postscript .alz=application/x-alz-compressed .ani=application/x-navi-animation .arj=application/x-arj .bat=application/x-msdos-program .bcpio=application/x-bcpio .boz=application/x-bzip2 .bz=application/x-bzip .bz2=application/x-bzip2 .cab=application/vnd.ms-cab-compressed .cat=application/vnd.ms-pki.seccat .ccn=application/x-cnc .cco=application/x-cocoa .cdf=application/x-cdf .cer=application/x-x509-ca-cert .chm=application/vnd.ms-htmlhelp .chrt=application/vnd.kde.kchart .cil=application/vnd.ms-artgalry .class=application/java-vm .com=application/x-msdos-program .clp=application/x-msclip .cpio=application/x-cpio .cqk=application/x-calquick .crd=application/x-mscardfile .crl=application/pkix-crl .csh=application/x-csh .dar=application/x-dar .dbf=application/x-dbase .dcr=application/x-director .deb=application/x-debian-package .dir=application/x-director .dist=vnd.apple.installer+xml .distz=vnd.apple.installer+xml .dll=application/x-msdos-program .dmg=application/x-apple-diskimage .doc=application/msword .dot=application/msword .dvi=application/x-dvi .dxr=application/x-director .ebk=application/x-expandedbook .eps=application/postscript .evy=application/envoy .exe=application/x-msdos-program .fdf=application/vnd.fdf .fif=application/fractals .flm=application/vnd.kde.kivio .fml=application/x-file-mirror-list .gzip=application/x-gzip .gnumeric=application/x-gnumeric .gtar=application/x-gtar .gz=application/x-gzip .hdf=application/x-hdf .hlp=application/winhlp .hpf=application/x-icq-hpf .hqx=application/mac-binhex40 .hta=application/hta .ims=application/vnd.ms-ims .ins=application/x-internet-signup .iii=application/x-iphone .iso=application/x-iso9660-image .jar=application/java-archive .karbon=application/vnd.kde.karbon .kfo=application/vnd.kde.kformula .kon=application/vnd.kde.kontour .kpr=application/vnd.kde.kpresenter .kpt=application/vnd.kde.kpresenter .kwd=application/vnd.kde.kword .kwt=application/vnd.kde.kword .latex=application/x-latex .lha=application/x-lzh .lcc=application/fastman .lrm=application/vnd.ms-lrm .lz=application/x-lzip .lzh=application/x-lzh .lzma=application/x-lzma .lzo=application/x-lzop .lzx=application/x-lzx .m13=application/x-msmediaview .m14=application/x-msmediaview .mpp=application/vnd.ms-project .mvb=application/x-msmediaview .man=application/x-troff-man .mdb=application/x-msaccess .me=application/x-troff-me .ms=application/x-troff-ms .msi=application/x-msi .mpkg=vnd.apple.installer+xml .mny=application/x-msmoney .nix=application/x-mix-transfer .o=application/x-object .oda=application/oda .odb=application/vnd.oasis.opendocument.database .odc=application/vnd.oasis.opendocument.chart .odf=application/vnd.oasis.opendocument.formula .odg=application/vnd.oasis.opendocument.graphics .odi=application/vnd.oasis.opendocument.image .odm=application/vnd.oasis.opendocument.text-master .odp=application/vnd.oasis.opendocument.presentation .ods=application/vnd.oasis.opendocument.spreadsheet .ogg=application/ogg .odt=application/vnd.oasis.opendocument.text .otg=application/vnd.oasis.opendocument.graphics-template .oth=application/vnd.oasis.opendocument.text-web .otp=application/vnd.oasis.opendocument.presentation-template .ots=application/vnd.oasis.opendocument.spreadsheet-template .ott=application/vnd.oasis.opendocument.text-template .p10=application/pkcs10 .p12=application/x-pkcs12 .p7b=application/x-pkcs7-certificates .p7m=application/pkcs7-mime .p7r=application/x-pkcs7-certreqresp .p7s=application/pkcs7-signature .package=application/vnd.autopackage .pfr=application/font-tdpfr .pkg=vnd.apple.installer+xml .pdf=application/pdf .pko=application/vnd.ms-pki.pko .pl=application/x-perl .pnq=application/x-icq-pnq .pot=application/mspowerpoint .pps=application/mspowerpoint .ppt=application/mspowerpoint .ppz=application/mspowerpoint .ps=application/postscript .pub=application/x-mspublisher .qpw=application/x-quattropro .qtl=application/x-quicktimeplayer .rar=application/rar .rdf=application/rdf+xml .rjs=application/vnd.rn-realsystem-rjs .rmf=application/vnd.rmf .rmp=application/vnd.rn-rn_music_package .rmx=application/vnd.rn-realsystem-rmx .rnx=application/vnd.rn-realplayer .rpm=application/x-redhat-package-manager .rsml=application/vnd.rn-rsml .rtsp=application/x-rtsp .rss=application/rss+xml .scm=application/x-icq-scm .ser=application/java-serialized-object .scd=application/x-msschedule .sda=application/vnd.stardivision.draw .sdc=application/vnd.stardivision.calc .sdd=application/vnd.stardivision.impress .sdp=application/x-sdp .setpay=application/set-payment-initiation .setreg=application/set-registration-initiation .sh=application/x-sh .shar=application/x-shar .shw=application/presentations .sit=application/x-stuffit .sitx=application/x-stuffitx .skd=application/x-koan .skm=application/x-koan .skp=application/x-koan .skt=application/x-koan .smf=application/vnd.stardivision.math .smi=application/smil .smil=application/smil .spl=application/futuresplash .ssm=application/streamingmedia .sst=application/vnd.ms-pki.certstore .stc=application/vnd.sun.xml.calc.template .std=application/vnd.sun.xml.draw.template .sti=application/vnd.sun.xml.impress.template .stl=application/vnd.ms-pki.stl .stw=application/vnd.sun.xml.writer.template .svi=application/softvision .sv4cpio=application/x-sv4cpio .sv4crc=application/x-sv4crc .swf=application/x-shockwave-flash .swf1=application/x-shockwave-flash .sxc=application/vnd.sun.xml.calc .sxi=application/vnd.sun.xml.impress .sxm=application/vnd.sun.xml.math .sxw=application/vnd.sun.xml.writer .sxg=application/vnd.sun.xml.writer.global .t=application/x-troff .tar=application/x-tar .tcl=application/x-tcl .tex=application/x-tex .texi=application/x-texinfo .texinfo=application/x-texinfo .tbz=application/x-bzip-compressed-tar .tbz2=application/x-bzip-compressed-tar .tgz=application/x-compressed-tar .tlz=application/x-lzma-compressed-tar .tr=application/x-troff .trm=application/x-msterminal .troff=application/x-troff .tsp=application/dsptype .torrent=application/x-bittorrent .ttz=application/t-time .txz=application/x-xz-compressed-tar .udeb=application/x-debian-package .uin=application/x-icq .urls=application/x-url-list .ustar=application/x-ustar .vcd=application/x-cdlink .vor=application/vnd.stardivision.writer .vsl=application/x-cnet-vsl .wcm=application/vnd.ms-works .wb1=application/x-quattropro .wb2=application/x-quattropro .wb3=application/x-quattropro .wdb=application/vnd.ms-works .wks=application/vnd.ms-works .wmd=application/x-ms-wmd .wms=application/x-ms-wms .wmz=application/x-ms-wmz .wp5=application/wordperfect5.1 .wpd=application/wordperfect .wpl=application/vnd.ms-wpl .wps=application/vnd.ms-works .wri=application/x-mswrite .xfdf=application/vnd.adobe.xfdf .xls=application/x-msexcel .xlb=application/x-msexcel .xpi=application/x-xpinstall .xps=application/vnd.ms-xpsdocument .xsd=application/vnd.sun.xml.draw .xul=application/vnd.mozilla.xul+xml .z=application/x-compress .zoo=application/x-zoo .zip=application/x-zip-compressed .wml=text/vnd.wap.wml .wmlc=application/vnd.wap.wmlc .wmls=text/vnd.wap.wmlscript .wmlsc=application/vnd.wap.wmlscriptc .asm=text/x-asm .p=text/x-pascal .pas=text/x-pascal .cs=text/x-csharp .c=text/x-csrc .c++=text/x-c++src .cpp=text/x-c++src .cxx=text/x-c++src .cc=text/x-c++src .h=text/x-chdr .h++=text/x-c++hdr .hpp=text/x-c++hdr .hxx=text/x-c++hdr .hh=text/x-c++hdr .java=text/x-java .css=text/css .js=text/javascript .htm=text/html .html=text/html .xhtml=application/xhtml+xml .xht=application/xhtml+xml .ls=text/javascript .mocha=text/javascript .shtml=server-parsed-html .sgm=text/sgml .sgml=text/sgml .mht=message/rfc822 .json=application/json .csv=text/csv .xlsx=application/vnd.openxmlformats-officedocument.spreadsheetml.sheet .docx=application/vnd.openxmlformats-officedocument.wordprocessingml.document .manifest=text/cache-manifest .appcache=text/cache-manifest .m4v=video/mp4 .properties=text/plain .ttf=text/plain .woff=text/plain .woff2=text/plain .eot=text/plain .otf=text/plain 1 Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 28, 2021 Share Posted October 28, 2021 20 minutes ago, x11 said: Где храниться этот список запрещенных или разрешенных расширений файлов? UniServerModule.MimeTable 1 Quote Link to comment Share on other sites More sharing options...
x11 Posted October 28, 2021 Author Share Posted October 28, 2021 MimeTable.AddMimeType('log', 'text/plain'); Я так понимаю, нужно добавить это строку. Но когда правильно? Это нужно делать перед каждым скачиванием или только один раз при старте приложения в серверном модуле или в главном модуле? Quote Link to comment Share on other sites More sharing options...
Sherzod Posted October 28, 2021 Share Posted October 28, 2021 3 minutes ago, x11 said: Я так понимаю, нужно добавить это строку. Да. 3 minutes ago, x11 said: приложения в серверном модуле UniGUIServerModuleBeforeInit Quote Link to comment Share on other sites More sharing options...
x11 Posted December 20, 2023 Author Share Posted December 20, 2023 On 10/28/2021 at 1:28 PM, Sherzod said: Да. подскажите, а что написать вместо log, чтобьі скачать файл без расширения? MimeTable.AddMimeType('???', 'text/plain'); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.