查找

文章
· 六月 26, 2024 阅读大约需 2 分钟

Comment télécharger des fichiers images à partir d'un serveur FTP ?

InterSystems FAQ rubric

La procédure de téléchargement à partir d'un serveur FTP est la suivante.

1. Télécharger le fichier image sur le serveur FTP

 set tmpfile="c:\temp\test.jpg"
 set ftp=##class(%Net.FtpSession).%New() 
 // connect to FTP server
 do ftp.Connect("","<username>","<password>")
 // set transfer mode to BINARY
 do ftp.Binary()
 // Move to the directory to upload
 do ftp.SetDirectory("/temp/upload")
 // Prepare a stream of files to upload  
 set file=##class(%File).%New(tmpfile)
 do file.Open("UK\BIN\")
 // upload file
 // 1st argument: File name to create at upload destination
 // 2nd argument: File stream to upload
 do ftp.Store("test.jpg",file)
 // Logout from ftp server
 do ftp.Logout()
 // close the file
 do file.Close()
 // (Optional) Delete the uploaded file
 //do ##class(%File).Delete(tmpfile)

2. Télécharger le fichier image à partir du serveur FTP

   set ftp=##class(%Net.FtpSession).%New()     // Connect to ftp server
    do ftp.Connect("","<username>","<password>")     // Set the transfer mode to BINARY
    do ftp.Binary()     // Prepare a file stream to download and store
    set stream=##class(%FileBinaryStream).%New()
    do stream.LinkToFile("c:\temp\testdownload.jpg")
   // Go to the download directory
    do ftp.SetDirectory("/temp/download")     // Download the file and close the stream
    do ftp.Retrieve("test.jpg",stream)
    do stream.SaveStream()
    Set stream=""     // Logout from the ftp server
    do ftp.Logout()

讨论 (0)1
登录或注册以继续
问题
· 六月 25, 2024

How to send WRITE formatted output to a variable

I'm trying to keep all writes in local memory.

If you have    S %A="""HI THERE"",!,#,33.33,"" "",$ZTIMESTAMP"

and you         O 2 U 2 W @%A C 2 ZW ^SPOOL                    
^SPOOL(1,1)="HI THERE"_$c(13,10)
^SPOOL(1,2)=$c(13,12)
^SPOOL(1,3)="33.33 67016,59246.6188873"

It works just fine and the output is in the ^SPOOL global. 

However, I'm trying to avoid writing to disk.

I can't find anything besides using the SPOOL device that will allow the use of the "@" indirection.

I tried using streams but it will not allow @indirection.  Neither will set, or execute, or anything.

Is there any easy way to just set a variable to the formatted write output that the @indirection creates??

Thanks!

4 Comments
讨论 (4)2
登录或注册以继续
问题
· 六月 25, 2024

SQL DatePart Not Working With ISO 8601 Formatted Date & Time

Given a properly formatted ISO 8601 date time of 2024-06-23T06:03:00Z using SQL DatePart results in an error:

  [SQLCODE: <-400>:<Fatal error occurred>]

  [%msg: <Invalid input to DATEPART() function: datepart='ss', datetime value='2024-06-23T06:03:00Z')>]

If I remove the trailing Z (for Zulu / UTC time) and leave the T, DatePart works fine.

I have also tried various ± offsets from UTC e.g. +0400 and that also results in the same SQL error

I can Trim the trailing "Z", but I would hope that DatePart would work with an acceptably formatted ISO 8601 date time string without having to go through the machinations of trimming the data.

Any help or suggestions on how to use SQL DatePart with ISO 8601 formatted Date Time strings would be appreciated.

This is the query I was experimenting with:

select 'YEAR: '||DATEPART(YEAR,'2024-06-23T06:03:00Z') 
UNION
select 'MONTH: '||DATEPART(MONTH,'2024-06-23T06:03:00Z') 
UNION
select 'DAY: '||DATEPART(DAY,'2024-06-23T06:03:00Z')
UNION
select 'HOUR: '||DATEPART(HOUR,'2024-06-23T06:03:00Z')
UNION 
select 'MINUTE: '||DATEPART(MINUTE,'2024-06-23T06:03:00Z')
UNION
select 'SECOND: '||DATEPART(SECOND,'2024-06-23T06:03:00Z')

2 Comments
讨论 (2)2
登录或注册以继续
问题
· 六月 25, 2024

How can i see the request size in kilobytes/megabytes?

I need to be able to take the size of the request from a given %CSP.request

however it seems the best the docs suggest is to get the length of characters in  the request (using $order and Get, Count)...
this is not good enough for what I need to do, Any suggestions?
I scanned the docs and couldn't find anything.

5 Comments
讨论 (5)1
登录或注册以继续
问题
· 六月 25, 2024

How to remove line feed and carriage return from start and end, but not from the middle of a string

Hello,

Thanks for reading this question.

We need to remove the line feeds and carriage returns from start and end, but not from the middle of a string

We have tested the following ways:

set output = $ZStrip("[line feed](carriage return) str [line feed](carriage return) ing [line feed](carriage return)","<>C")

But it removes also control characters which we need to preserve...

Also we have tested:

set output = $REPLACE("[line feed](carriage return) str [line feed](carriage return) ing [line feed](carriage return)",$C(13,10),"")

But it deletes line feed and carriage return at the middle of the string, so it is not what we need...

How would you recommend us to implement it.

We have read:

https://community.intersystems.com/post/trimming

https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...

https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...

https://community.intersystems.com/post/zstrip-clean-string

https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...

 

Could you help us please?

Thanks.

7 Comments
讨论 (7)3
登录或注册以继续