【发布时间】:2022-08-24 08:25:51
【问题描述】:
我正在尝试将 Photoshop API 集成到 Web 应用程序中。在最基本的阶段,我有一个带有简单 /upload 端点的快速应用程序,它执行以下操作:
- 从我的 Dropbox 中获取图像链接和 Photoshop 操作。我使用了 SDK 并参考了这里的文档https://www.dropbox.com/developers/documentation/http/documentation#files-get_temporary_link。
- 按照https://www.dropbox.com/developers/documentation/http/documentation#files-get_temporary_upload_link 的文档,以与上述类似的方式从保管箱获取上传链接
- 使用此处 https://developer.adobe.com/photoshop/photoshop-api-docs/api/#operation/photoshopActions 的 Photoshop API 参考,我尝试从 Adobe Photoshop API(试用版)执行操作。
以下代码是主要部分所在:
app.post(\'/upload\', upload.any() , async (req, res, next) => { // console.log(req.files); try { const file = req.files[0]; const fileData = await getFileLink(\'/scott.jpg\'); const fileLink = fileData.result.link; const actionData = await getFileLink(\'/Black-White-Sample.atn\'); const actionLink = actionData.result.link; const uploadLink = await getUploadLink(); const response = await fetch(\'https://image.adobe.io/pie/psdService/text\', { method: \'POST\', headers: { Authorization: `Bearer ${ADOBE_ACCESS_TOKEN}`, \"x-api-key\": ADOBE_CLIENT_ID, \"Content-Type\": \"application/json\" }, body: { inputs: [ { storage: \"dropbox\", href: fileLink } ], options: { actions: [ { storage: \"dropbox\", href: uploadLink } ] }, outputs: [ { storage: \"dropbox\", type: \'image/png\', href: `${uploadLink}` } ] } }); res.send(\'success\'); } catch(err) { console.log(\'ERROR XOXOXOXO\' + err); } }, (err) => { console.log(err); })我收到 500 内部服务器错误。该请求不会引发错误,发送“成功”消息和响应。而且响应的结构方式,我什么都想不通。已经尝试了几个小时,谷歌搜索等等。但似乎根本没有资源可以做这样的事情。我得到的回应是:
RESPONSE =================== Body { url: \'https://image.adobe.io/pie/psdService/photoshopActions\', status: 500, statusText: \'Internal Server Error\', headers: Headers { _headers: { server: [Array], date: [Array], \'content-type\': [Array], \'content-length\': [Array], connection: [Array], \'access-control-allow-credentials\': [Array], \'access-control-allow-headers\': [Array], \'access-control-allow-methods\': [Array], \'access-control-allow-origin\': [Array], exposeheaders: [Array], \'strict-transport-security\': [Array], \'x-request-id\': [Array] } }, ok: false, body: PassThrough { _readableState: ReadableState { objectMode: false, highWaterMark: 16384, buffer: BufferList { head: [Object], tail: [Object], length: 1 }, length: 236, pipes: [], flowing: null, ended: true, endEmitted: false, reading: false, constructed: true, sync: false, needReadable: false, emittedReadable: false, readableListening: false, resumeScheduled: false, errorEmitted: false, emitClose: true, autoDestroy: true, destroyed: false, errored: null, closed: false, closeEmitted: false, defaultEncoding: \'utf8\', awaitDrainWriters: null, multiAwaitDrain: false, readingMore: false, dataEmitted: false, decoder: null, encoding: null, [Symbol(kPaused)]: null }, _events: [Object: null prototype] { prefinish: [Function: prefinish] }, _eventsCount: 1, _maxListeners: undefined, _writableState: WritableState { objectMode: false, highWaterMark: 16384, finalCalled: true, needDrain: false, ending: true, ended: true, finished: true, destroyed: false, decodeStrings: true, defaultEncoding: \'utf8\', length: 0, writing: false, corked: 0, sync: false, bufferProcessing: false, onwrite: [Function: bound onwrite], writecb: null, writelen: 0, afterWriteTickInfo: null, buffered: [], bufferedIndex: 0, allBuffers: true, allNoop: true, pendingcb: 0, constructed: true, prefinished: true, errorEmitted: false, emitClose: true, autoDestroy: true, errored: null, closed: false, closeEmitted: false, [Symbol(kOnFinished)]: [] }, allowHalfOpen: true, [Symbol(kCapture)]: false, [Symbol(kCallback)]: null }, bodyUsed: false, size: 0, timeout: 0, _raw: [], _abort: false }保管箱功能是:
async function getFileLink(path) { try { const fileLink = await dbx.filesGetTemporaryLink({path: path}); // console.log(fileLink); return fileLink; } catch(err) { console.log(err); } } async function getUploadLink() { try { const res = await dbx.filesGetTemporaryUploadLink({ commit_info: { autorename: true, mode: \'add\', mute: false, path: \'/New Folder\', strict_conflict: false } }) return res.result.link } catch(err) { console.log(err); } }我究竟做错了什么?我不认为它与 API 的试用版有关。而且我真的没有其他东西可以从我身边检查了。任何有经验的人的帮助将不胜感激。
标签: javascript node.js photoshop photoshop-sdk