diff --git a/README.md b/README.md index 479d9fd..04313ca 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ Config Environment Variables: - bucket_name: Oracle bucket name. e.g. `my-bucket-name` - namespace: Oracle namespace. - tinypng_api_key: Get your tinypng api key from https://tinypng.com/developers to compress images before uploading. +- short_url: You can add proxy to cloudflare or aws lambda to make url short. Example: https://gist.github.com/PatelUtkarsh/0438735990e0b6f373b4deaf7f9be277 **Note** 🗒️: if tinypng_api_key is set, it will compress original image and replace it before uploading to object storage. @@ -40,6 +41,8 @@ TinyPng will compress png, webp and jpg images. upload TYPE-FILENAME-HERE ``` +### Issue with python 2? +Read setup guide at https://www.alfredapp.com/help/kb/python-2-monterey/ ## Forked source: 🙌 - https://github.com/tonyxu-io/Alfred-Workflow-Upload-S3 diff --git a/upload-s3.py b/upload-s3.py index 6c33e20..f8dd9f1 100644 --- a/upload-s3.py +++ b/upload-s3.py @@ -52,7 +52,14 @@ def main(wf): endpoint_url="https://%s.compat.objectstorage.%s.oraclecloud.com" %(namespace, region_name) ) s3.upload_file(file_path, bucket_name, file_name, ExtraArgs={'ContentType': content_type}) - output = "https://objectstorage.%s.oraclecloud.com/n/%s/b/%s/o/%s" %(region_name,namespace,bucket_name,file_name) + shorturl = os.getenv('shorturl') + # if short url is not empty and exists. + if shorturl: + if shorturl[len(shorturl)-1] != "/": + shorturl = shorturl + "/" + output = "%s%s" %(shorturl,file_name) + else: + output = "https://objectstorage.%s.oraclecloud.com/n/%s/b/%s/o/%s" %(region_name,namespace,bucket_name,file_name) print (output,end='') if __name__ == '__main__':