Send Email Attachments with Unicode Filenames in Django

使用 MIMEApplication 並設置 attachment 的 header 不然如果檔名有中文的話 用 Gmail 收到的附件檔名會是 noname def withdraw_send_email(request, pk): withdraw = get_object_or_404(Withdraw, pk=pk) email = '[email protected]' subject = _(u'Packer 數位發行服務') body = render_to_string('dps/email/withdraw_notice.html', {}) message = EmailMessage( subject=subject, body=body, to=[email, ], ) message.content_subtype = 'html' from email.mime.application import MIMEApplication # 檔名包含中文的話,要用這種方式 Gmail 收到的附件檔名才不會是 noname filename = '%s 結算表.xlsx' % (withdraw.serial_number[:6].encode('utf-8'))… Read More

Upload your Java Artifacts to Maven Central Repository

你需要: 一個使用 Maven 管理的 Java project(廢話) 一個 GPG key(deploy 的時候會用來 sign 要提交的 .jar) 一個 Sonatype JIRA 的帳號 開一張 JIRA 的 ticket 告訴 Sonatype 的人你要發佈 library,告知他們你的 groupId 按照 Requirements 的指示完善你的 pom.xml deploy 到 snapshot repository deploy 到 staging repository 在 OSSRH 的 Staging Repositories 把你剛剛 deploy 的 library 給 close 掉,這樣才算是 release 回到那張 ticket,通知 Sonatype 讓他們把你的… Read More

Maven: The De Facto Build Tool for JVM Projects

Install # on Mac OS X $ brew install maven $ brew install maven-completion ref: https://maven.apache.org/index.html Commands # create project: interactive mode $ mvn archetype:generate -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=true # create project: non-interactive mode $ mvn archetype:generate -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false -DgroupId=ws.vinta.pangu -DartifactId=pangu # download dependencies $ mvn dependency:copy-dependencies # download dependencies to a specific directory $ mvn dependency:copy-dependencies… Read More