Nova postagem

Rechercher

Artigo
· Fev. 25 2min de leitura

クライアントからPOSTされた ファイルを受け取るRESTサービスを作成する方法

これは InterSystems FAQ サイトの記事です。
 

以下の様なCurl コマンドで送信したファイルを受け取るRESTサービスを作成する方法を紹介します。

curl -X POST "http://localhost/api/upload?a=123&b=999" -F file=@"C:/temp/a.csv"

クライアントからPOSTされたファイルを受け取ってサーバーに保存するRESTサービスは以下の様に作成します。 

Class User.MyREST Extends %CSP.REST
{
Parameter HandleCorsRequest = 1;
XData UrlMap
{
 <Routes>
  <Route Url="/uploadimg" Method="POST" Call="readMimeData" />
  </Routes>
}
ClassMethod readMimeData() As %Status
{
    set upload=$g(%request.MimeData("csvfile", 1))
    set fname=%request.MimeData("csvfile",1).FileName
    set file=##class(%File).%New("c:\temp\"_fname)
    do file.Open("NWU")
    do file.CopyFrom(upload)
    set st = file.%Save()
    if st {
        write fname_" アップロード完了!!"
    } else {
        write fname_" アップロード失敗"
    }
    do file.Close()
    quit $$$OK
 }
}

このRESTサービスをクライアントから呼び出すために、以下の様な設定を行います。

管理ポータル>システム管理>セキュリティ>アプリケーション>ウェブ・アプリケーション>新しいウェブ・アプリケーションを作成の所で上で作成したRESTディスパッチクラスを登録します。 

名前: /api/upload

ネームスペース:  そのクラスを保存したネームスペース

RESTを有効にして、ディスパッチクラスにUser.MyRESTを設定する 

この設定はAPIを呼び出して実行することもできます。

zn "%SYS"
set sec = ##class("Security.Applications").%New()
set sec.Name = "/api/upload"
set sec.NameSpace = "USER"
set sec.DispatchClass ="User.MyREST"
set sec.AutheEnabled = 96
set status = sec.%Save()
Discussão (0)1
Entre ou crie uma conta para continuar
Anúncio
· Fev. 24

Reminder: Seeking Exam Design Feedback for InterSystems ObjectScript Specialist Certification Exam

Hi Everyone!

The Certification Team of InterSystems Learning Services is currently developing an InterSystems ObjectScript Specialist certification exam. Earlier this month we reached out to our community for feedback that will help us evaluate and establish the contents of this exam. We are still currently accepting responses and would love to hear your feedback!

Please note that this is one of two exams being developed to replace our InterSystems IRIS Core Solutions Developer exam. You can find more details about the other exam, InterSystems IRIS Developer Professional exam, here

How do I provide my input? Complete our Job Task Analysis (JTA) survey! We will present you with a list of job tasks, and you will rate them on their importance as well as other factors. 

How much effort is involved? It takes about 20-30 minutes to fill out the survey. You can be anonymous or identify yourself and ask us to get back to you.  

How can I access the survey? You can access the survey here

  • Survey does not work well on mobile devices - you can access it, but it might involve some scrolling.
  • Survey can be resumable if you return to it on the same device in the same browser – Use the Next button at the bottom of the page to save your answers.
  • Survey will close on March 15, 2025.

What’s in it for me? You get to weigh in on the exam topics for our new exam, and as a token of our appreciation, all participants will be entered into a raffle where 10 lucky winners will receive a $50 Tango gift card, Global Masters points, and potentially other swag. Note: Tango gift cards are only available for US-based participants. InterSystems and VA employees are not eligible. 

Here are the exam title and the definition of the target role: 

InterSystems ObjectScript Specialist 

An IT professional who is familiar with object-oriented programming concepts and: 

  • creates InterSystems IRIS classes, 
  • writes and reviews InterSystems ObjectScript and SQL code, and 
  • uses both objects and SQL for data access. 

At least six months to one year of experience with the tasks listed above is recommended. 

Discussão (0)1
Entre ou crie uma conta para continuar
Anúncio
· Fev. 24

[Video] FHIR Performance Benchmarking

Hi Community,

Enjoy the new video on InterSystems Developers YouTube:

⏯ FHIR Performance Benchmarking @ Global Summit 2024

Join us to learn about the results of our latest FHIR benchmark tests using a new FHIR search strategy.

Presenters
🗣 @Patrick Jamieson, Product Manager, InterSystems
🗣 @Adarsh Banad, FHIR Performance Engineer, InterSystems  

Don’t miss out! Watch now and level up your skills — and don’t forget to subscribe! 👍

Discussão (0)1
Entre ou crie uma conta para continuar
Pergunta
· Fev. 24

Reading HTTP multipart/form messages from EnsLib.HTTP.GenericMessage object.

Hello everyone!

I have set up an EnsLib.REST.GenericService with an  EnsLib.HTTP.InboundAdapter which forwards the http requests received by a web app to my Business Process. 

I would like to parse HTTP multipart/form messages I am receving and be able to iterate over the various fields within the request body, accessing its content type and the content itself.

As far as I understand I should use the %Net.MIMEReader class which should return a list of %Net.MIMEPart, one for each field within the request. However if I do : 

Set mimeReader = ##class(%Net.MIMEReader).%New()
Set sc = mimeReader.OpenStream(pRequest.Stream)
Set sc = mimeReader.ReadMIMEMessage(.message)
Set parts = message.Parts.Count()

 

it results that the number of Parts is zero, Even though I am sending a request with postman containing two fields. This is how it looks like:

POST ....
Host: localhost:1888
Content-Length: 290
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="first field"
Content-Type: text/plain

Test text
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="third field"
Content-Type: text/plain

Test text 2
------WebKitFormBoundary7MA4YWxkTrZu0gW--

If anyone as any clue on how to handle this case suggestions will be much appreciated!

4 Comments
Discussão (4)1
Entre ou crie uma conta para continuar
Resumo
· Fev. 24

Publicações Desenvolvedores InterSystems, Fevereiro 17 - 23, 2025, Resumo