Coder Social home page Coder Social logo

Comments (2)

DimosthenisK avatar DimosthenisK commented on July 27, 2024 3

I have already created a quick service like that, and you are free to modify it and add it to the core module. It currently looks like this:

import { Injectable } from '@nestjs/common';
import * as azure from '@azure/storage-blob';
import { ConfigService } from '../config/config.service';
import {
    AccountSASServices,
    AccountSASResourceTypes,
} from '@azure/storage-blob';

@Injectable()
export class AzureSASService {
    private credential: azure.SharedKeyCredential;
    constructor(private readonly configService: ConfigService) {
        this.credential = new azure.SharedKeyCredential(
            this.configService.get('AZURE_STORAGE_ACCOUNT'),
            this.configService.get('AZURE_STORAGE_ACCOUNT_KEY')
        );
    }
    getNewSASKey() { //We should probably add a config object here
        let expiryTime = new Date();
        let startTime = new Date();
        expiryTime.setMonth(new Date().getMonth() + 1);
        startTime.setFullYear(startTime.getFullYear() - 10);
        return (
            '?' +
            azure
                .generateAccountSASQueryParameters(
                    {
                        expiryTime,
                        services: AccountSASServices.parse('b').toString(),
                        resourceTypes: AccountSASResourceTypes.parse(
                            'sco'
                        ).toString(),
                        permissions: azure.ContainerSASPermissions.parse(
                            'racwdl'
                        ).toString(),
                        startTime,
                        ipRange: { start: '0.0.0.0', end: '255.255.255.255' },
                        protocol: azure.SASProtocol.HTTPSandHTTP,
                        version: '2018-11-09',
                    },
                    this.credential
                )
                .toString()
        );
    }
}

from azure-storage.

Roytangrb avatar Roytangrb commented on July 27, 2024 1

May I ask if there is any update on this issue.

Granting access to resources using SAS signed url is pretty common use case of Azure Blob Storage. Sometimes we don't want to use our server bandwidth for download and upload actions. The server might only take care of access management.

I could help with drafting the feature and raise a PR if help is wanted.

from azure-storage.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.