iOS一些小技巧 | 五

一,OSS私有文件增加验签,本地SDK在URL后增加签名,无需网络请求权限:

//
//
func ossImageUrlAddVerificationSignature(filePath: String) -> String? {
    
    guard let ossParamsModel = self.ossSignModel else {
        return nil;
    }
    
    let endpoint: String = ossParamsModel.endpoint;
    let accessKeyId: String = ossParamsModel.accessKeyId;
    let accessKeySecret: String = ossParamsModel.accessKeySecret;
    //objectKey为文件在OSS中的路径+文件名
    let objectKey: String = filePath;
    
    let credential = OSSStsTokenCredentialProvider(accessKeyId: accessKeyId, secretKeyId: accessKeySecret, securityToken: "");
    let client = OSSClient(endpoint: endpoint, credentialProvider: credential)
    let task = client.presignConstrainURL(withBucketName: AlibabaOSSImageServerBucketName, withObjectKey: objectKey, httpMethod: "GET", withExpirationInterval: 60 * 4, withParameters: [:]);
    var signatureUrl: String?;
    task.continue({ task in
        if nil == task.error {
            signatureUrl = task.result as? String;
        }
        return nil;
    });
    return signatureUrl;
}
//
//

二,git开启LFS上传大文件;

//1,安装
brew install git-lfs
//2,查看是否成功和版本
git lfs -v
//3,将本地大文件交给lfs管理,可多次执行
git lfs track "文件名"
//4,查看当前lfs管理的文件列表
git lfs track
//5,提交暂存区、本地及将大文件推送到远程管理,包括.gitattributes文件
git add .
git commit -m "msg"
git push
//6,再拉取一下大文件
git lfs pull
//7,将文件交给lfs管理,可执行多次
git lfs migrate import --include-ref=master --include="FlowerClassifier.mlmodel"
git lfs migrate import --include-ref=master --include="MLKitTextRecognitionCommon"
git lfs migrate import --include-ref=master --include="MLKitVisionKit"
git lfs migrate import --include-ref=master --include="MLKitXenoCommon"
//8,提交
git push --all --force
或
git push

三,bash和zsh之间的切换;

//
chsh -s /bin/bash
//
chsh -s /bin/zsh

Leave a Reply

Required fields are marked *