Phrase TMS API

文件数据类型((TMS))

文本由 Phrase Language AI 从英语机器翻译而得。

文件 `%1`数据类型用于将二进制数据发布到各种 API 调用中。每个包含至少一个类型=""参数文件的 Api 调用必须至少满足以下要求:

  • 必须使用 HTTP 请求方法。

  • 必须形成HTML规范中描述的多部分/表格数据请求。

示例

Java HttpClient

HttpClient httpclient = new DefaultHttpClient(); 
HttpPost httpPost = new HttpPost(webServerUrl);
MultipartEntity requestEntity = 新建 MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE, null, Charset.forName (“UTF-8”));
StringBody taskPart;
StringBody formatPart;
StringBody saveToTransMemoryPart;
StringBody setCompletedPart;
ByteArrayBody fileContentPart;
//... 用数据填充变量... //

reqEntity.addPart("task", taskPart);
reqEntity.addPart("format", formatPart);
reqEntity.addPart("saveToTransMemory", saveToTransMemoryPart);
reqEntity.addPart("setCompleted", setCompletedPart);
reqEntity.addPart("bilingualFile", fileContentPart);
httpPost.setEntity(reqEntity);

C++ Qt

QHttpMultiPart* multiPartData = new QHttpMultiPart( QHttpMultiPart::FormDataType );
QBuffer* buffer = new QBuffer( multiPartData );
buffer->open( QIODevice::WriteOnly );
//... 用数据填充缓冲区... //
writer.writeTo( buffer );
buffer->close();

QHttpPart filePart;
filePart.setHeader( QNetworkRequest::ContentTypeHeader, QVariant( "application/octet-stream" ) );
filePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant(QString("form-data; name=\"bilingualFile\"; filename=\"" ) + model->getFileInfos()[0].original + "\" ));
buffer->open( QIODevice::ReadOnly );
filePart.setBodyDevice( buffer );
multiPartData->append( filePart );
这篇文章有帮助吗?

Sorry about that! In what way was it not helpful?

The article didn’t address my problem.
I couldn’t understand the article.
The feature doesn’t do what I need.
Other reason.

Note that feedback is provided anonymously so we aren't able to reply to questions.
If you'd like to ask a question, submit a request to our Support team.
Thank you for your feedback.