Skip to content

Commit

Permalink
Remove image uploading to 3rd party service
Browse files Browse the repository at this point in the history
Fixes issue #4
  • Loading branch information
jozefizso committed Oct 25, 2024
1 parent 78ee680 commit a3c8cfd
Showing 1 changed file with 6 additions and 49 deletions.
55 changes: 6 additions & 49 deletions src/attachment.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2024 Cisco Systems, Inc.
// Licensed under MIT-style license (see LICENSE.txt file).

import * as core from '@actions/core'
import * as exec from '@actions/exec'
import * as os from 'os'
import * as path from 'path'

import {Activity} from './activity'
import {Dimensions} from './dimensions'
Expand All @@ -10,8 +10,6 @@ import {Parser} from './parser'
import {Reference} from '../dev/@types/Reference.d'
import {SortedKeyValueArray} from '../dev/@types/SortedKeyValueArray.d'

import sizeOf from 'image-size'

export interface Attachment {
uniformTypeIdentifier: string
name?: string
Expand All @@ -34,49 +32,8 @@ export async function exportAttachments(
activity.attachments = activity.attachments || []

if (activity.attachments) {
for (const attachment of activity.attachments) {
if (attachment.filename && attachment.payloadRef) {
const outputPath = path.join(os.tmpdir(), attachment.filename)
const image = await parser.exportObject(
attachment.payloadRef.id,
outputPath
)

let output = ''
const options = {
silent: true,
listeners: {
stdout: (data: Buffer) => {
output += data.toString()
}
}
}

try {
const dimensions: Dimensions = sizeOf(image)
attachment.dimensions = dimensions

if (image && core.getInput('token')) {
await exec.exec(
'curl',
[
'-X',
'POST',
'https://xcresulttool-file.herokuapp.com/file',
'-d',
image.toString('base64')
],
options
)
const response = JSON.parse(output)
if (response) {
attachment.link = response.link
}
}
} catch {
// no-op
}
}
}
core.debug(
`Attachments in activity '${activity.title}' will not be exported.`
)
}
}

0 comments on commit a3c8cfd

Please sign in to comment.