Skip to content

Commit

Permalink
Merge pull request #75 from mvdicarlo/develop
Browse files Browse the repository at this point in the history
v2.3.30
  • Loading branch information
mvdicarlo authored May 7, 2021
2 parents 3a0bd2b + 10bcae0 commit 605aaf4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 16 deletions.
2 changes: 1 addition & 1 deletion electron/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postybirb",
"version": "2.3.29",
"version": "2.3.30",
"description": "PostyBirb is an application that helps artists post art and other multimedia to multiple websites more quickly.",
"main": "main.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postybirb",
"version": "2.3.29",
"version": "2.3.30",
"scripts": {
"ng": "ng",
"compile": "ng build --vendor-chunk=false",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,10 @@ export class Subscribestar extends BaseWebsiteService {
.filter((f) => f)
.map((f) => fileAsFormDataObject(f));


const uploadPath = (body.match(/data-s3-upload-path=\\"(.*?)\\"/) || [])[1];
const uploadUrl = (body.match(/data-s3-url="(.*?)"/) || [])[1];
if (!uploadUrl || !uploadPath) {
const bucket = (body.match(/data-s3-bucket="(.*?)"/) || [])[1];
if (!uploadPath || !bucket) {
return Promise.reject(
this.createPostResponse('Issue getting upload data', body)
);
Expand All @@ -281,14 +282,22 @@ export class Subscribestar extends BaseWebsiteService {
const key = `${uploadPath}/${uuidv1()}.${file.options.filename
.split('.')
.pop()}`;
const presignUrl = `${this.BASE_URL}/presigned_url/upload?_=${Date.now()}&key=${encodeURIComponent(key)}&file_name=${encodeURIComponent(file.options.filename)}&content_type=${encodeURIComponent(file.options.contentType)}&bucket=${bucket}`;
const presign = await got.get(presignUrl, this.BASE_URL, cookies, postData.profileId);

let presignData = null;
try {
presignData = JSON.parse(presign.body);
} catch {
return Promise.reject(
this.createPostResponse('Failed to upload file', presign.body)
);
}

const postFile = await got.post(
uploadUrl,
presignData.url,
{
key,
acl: 'public-read',
success_action_Status: '201',
'Content-Type': file.options.contentType,
'x-amz-meta-original-filename': file.options.filename,
...presignData.fields,
file,
authenticity_token: csrf,
},
Expand All @@ -308,15 +317,14 @@ export class Subscribestar extends BaseWebsiteService {
);
}

if (postFile.success && postFile.success.response.statusCode === 201) {
if (postFile.success && postFile.success.response.statusCode >= 200 && postFile.success.response.statusCode <= 300) {
const xml = $($.parseXML(postFile.success.body));
const record: any = {
path: xml.find('Key').text(),
url: xml.find('Location').text(),
path: key,
url: `${presignData.url}/${key}`,
original_filename: file.options.filename,
content_type: file.options.contentType,
bucket: xml.find('Bucket').text(),
etag: xml.find('ETag').text(),
bucket,
authenticity_token: csrf,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class WeasylSubmissionForm extends BaseWebsiteSubmissionForm implements O

ngOnInit() {
super.ngOnInit();
this.folders = this.websiteService.getFolders(this.parentForm.getLoginProfileId()) || [];
this.folders = [{ id: '', title: 'None' }, ...this.websiteService.getFolders(this.parentForm.getLoginProfileId()) || []];
if (!this.formGroup.get('options')) this.formGroup.addControl('options', this.formBuilder.group(this.optionDefaults));
}

Expand Down

0 comments on commit 605aaf4

Please sign in to comment.