Skip to content

Commit

Permalink
added getZone
Browse files Browse the repository at this point in the history
  • Loading branch information
Allan-Nava authored Jun 4, 2024
1 parent 8228bbe commit e48a464
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 34 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/node-example-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Publish compress-nodeks example to release
on:
#push:
# branches: [ master, main ]
release:
types: [published]
jobs:
build:
permissions:
contents: write
packages: write
repository-projects: write
actions: write
deployments: write
checks: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
#
- name: Set output
id: vars
run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
- name: Check output
env:
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
run: |
echo $RELEASE_VERSION
echo ${{ steps.vars.outputs.tag }}
#
- run: cd example
- run: ls -l
- run: npm i
- run: npm run prepare
- run: npm run build
#
- name: Zip files for release
run: zip -r compress-nodejs-example-${{ steps.vars.outputs.tag }}.zip dist/

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./compress-nodejs-example-${{ steps.vars.outputs.tag }}.zip # Adjust according to your build output directory
asset_name: compress-nodejs-example-${{ steps.vars.outputs.tag }}.zip
asset_content_type: application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
},
"homepage": "https://github.com/HiWay-Media/compress-nodejs#readme",
"dependencies": {
"compress-nodejs": "^0.1.0"
"compress-nodejs": "^0.5.0"
}
}
4 changes: 4 additions & 0 deletions lib/compressjs/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ export const PRESIGNED_URL_S3 = `${GET_UPLOADS}/presignedUrl`;
export const S3_SPACE = `${GET_UPLOADS}/s3_space`;
export const ADD_VIDEO_THUMB = `${GET_UPLOADS}/add_thumb`;
export const SIGN_S3_URL = `${GET_UPLOADS}/sign_s3_url`;
// credentials
export const CREDENTIALS = `/external/credentials/`;
// customers
export const CUSTOMERS = `/external/customers/`;
export const GET_CUSTOMER_ZONE = `${CUSTOMERS}/s3`;
export const PERMITTED_FILE_EXTENSIONS = [
".mov",
".mpeg1",
Expand Down
61 changes: 28 additions & 33 deletions lib/compressjs/tangram.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
*
* Author: Allan Nava ([email protected])
* Author: Allan Nava ([email protected])
* Author: Antonio Borgese ([email protected])
* -----
* Last Modified:
* Modified By: Allan Nava ([email protected]>)
Expand All @@ -9,7 +10,7 @@
*
*/

import { TNGRM_BASE_URL, S3_SPACE, GET_CATEGORIES, PRESIGNED_URL_S3, ADD_VIDEO_THUMB, CREATE_UPLOAD, GET_RUNNING_SINGLE_INSTANCE, GET_RESTREAMERS, GET_RUNNING_INSTANCES, SCALE_RESTREAMER, GET_UPLOADS, GET_SINGLE_UPLOAD, SET_PUBLISHED_UPLOAD, SIGN_S3_URL, GET_JOBID_PROGRESS, CREDENTIALS, BULK_EVENTS_CREATE, RESTREAMER_HLS_START, RESTREAMER_HLS_STOP, RESTREAMER_PUSH_START, RESTREAMER_PUSH_STOP, RESTREAMER_PULL_START, RESTREAMER_PULL_STOP } from "./constants";
import { TNGRM_BASE_URL, S3_SPACE, GET_CATEGORIES, PRESIGNED_URL_S3, ADD_VIDEO_THUMB, CREATE_UPLOAD, GET_RUNNING_SINGLE_INSTANCE, GET_RESTREAMERS, GET_RUNNING_INSTANCES, SCALE_RESTREAMER, GET_UPLOADS, GET_SINGLE_UPLOAD, SET_PUBLISHED_UPLOAD, SIGN_S3_URL, GET_JOBID_PROGRESS, CREDENTIALS, BULK_EVENTS_CREATE, RESTREAMER_HLS_START, RESTREAMER_HLS_STOP, RESTREAMER_PUSH_START, RESTREAMER_PUSH_STOP, RESTREAMER_PULL_START, RESTREAMER_PULL_STOP, GET_CUSTOMER_ZONE } from "./constants";
// Import the EvaporateJS library
//import * from 'evaporate';
//
Expand Down Expand Up @@ -279,30 +280,6 @@ export class TangramClient {
let upload = await this.upload_s3(destination_folder, file, fileName);
console.log("upload ", upload);
return await this.encode(file_dest, file, title, tags, location_place, category_id);
/*return await fetch(TNGRM_BASE_URL + CREATE_UPLOAD, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
api_key: this.api_key,
title: title,
tags: tags,
category: parseInt(category_id),
location: location_place,
filename: file_dest,
size: parseInt(file.size),
reporter_email: `${this.customer_name}@tngrm.io`,
}),
})
.then((res) => {
if (!res.ok) {
throw new Error(
`something went wrong during create upload, ${res.status} ${res.statusText}`
);
}
return res.json();
});*/
//
}

Expand Down Expand Up @@ -737,15 +714,33 @@ export class TangramClient {
}
return res.json();
});
// .then((json_res) => {
// console.log(json_res);
// return json_res.data;
// })
// .catch((err) => {
// console.log(err);
// });
}


/**
* Need to call before upload s3
*
* @returns customer_s3
*/
async getZone() {
return await fetch(TNGRM_BASE_URL + GET_CUSTOMER_ZONE, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
api_key: this.api_key,
client_id: this.client_id,
})
}).then((res) => {
if (!res.ok) {
throw new Error(
`something went wrong during get getZone, ${res.status} ${res.statusText}`
);
}
return res.json();
});
}
/**
* jobid is compulsory
* example: get_single_upload(1000)
Expand Down

0 comments on commit e48a464

Please sign in to comment.