This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

azure-storage-upload-file-server

0.0.9 • Public • Published

File upload to Azure Blob storage

Uploads a single file to blob store.

How it works

Node.js express server receives file and streams to Azure Blob Storage. ExpressJS server doesn't need to have significant storage but it should have memory sufficient to handle streaming. If messaging is enabled, the body of the form is part of the message, along with results of other operations such as create a blob. Messaging is on by default, to disable, set app.config.messages.enabled to false in server.js.

Changing the default client display

To change the client display, change the /client/index.html. The client directory is only used for client display so you can drop in whatever framework of choice you have such as Angular or React files. The assets directory is configured as the location for other static files.

Steps to use

  1. npm install
  2. Copy .env.sample and rename to .env. file.
  3. Create Azure Storage resource.
  4. Add resource values to .env:
    • Storage connection string
    • Storage url to construct URLs for files
    • Session secret (not currently used)
  5. npm start
  6. Open browser to http://localhost:3000.
  7. Select file, enter container and directory (within) container. Container and directory values are lower-cased before used.
  8. Submit form.
  9. Open Storage Explorer or Azure portal and view resource's container and directory. Filename has a unique ID pre-pended to the file.

Steps to test

  1. npm install
  2. npm test

JSON Response on success

Response is a JSON object:

{
    "filename": "5347493062294617-kb.1.json",
    "originalname": "kb.1.json",
    "size": 61135,
    "path": "mycontainer-5/mydirectory-5/5347493062294617-kb.1.json",
    "url": "myresource.file.core.windows.netmycontainer-5/mydirectory-5/5347493062294617-kb.1.json",
    "messaging": true,
    "instructions": {
        "container": "myContainer-5",
        "directory": "myDirectory-5"
    },
    "blobResults": {
        "container": "mycontainer-5",
        "name": "mydirectory-5/5347493062294617-kb.1.json",
        "lastModified": "Wed, 31 Jul 2019 15:51:11 GMT",
        "etag": "\"0x8D715CEE8FAAADE\"",
        "contentLength": "0",
        "requestId": "4900fd16-401e-0013-39b7-47e233000000",
        "contentSettings": {
            "contentMD5": "88r1GLLBsrZwgL5yKDnvSQ=="
        }
    },
    "queueResults": {
        "messageId": "8118b3f4-6dd5-46f0-8743-576879624b65",
        "insertionTime": "Wed, 31 Jul 2019 15:51:11 GMT",
        "expirationTime": "Wed, 07 Aug 2019 15:51:11 GMT",
        "popReceipt": "AgAAAAMAAAAAAAAAiSPyxrdH1QE=",
        "timeNextVisible": "Wed, 31 Jul 2019 15:51:11 GMT"
    },
    "result": {
        "container": "mycontainer-5",
        "name": "mydirectory-5/5347493062294617-kb.1.json",
        "lastModified": "Wed, 31 Jul 2019 15:51:11 GMT",
        "etag": "\"0x8D715CEE8FAAADE\"",
        "contentLength": "0",
        "requestId": "4900fd16-401e-0013-39b7-47e233000000",
        "contentSettings": {
            "contentMD5": "88r1GLLBsrZwgL5yKDnvSQ=="
        }
    }
}

Queue message example

The JSON object sent to messaging is JSON.stringified in this project, then the Storage SDK encodes for XML safety. Reading the message back out with the SDK will undo the XML encoding.

{"filename":"48041395381658214-kb.json","originalname":"kb.json","size":54992,"path":"function-blob-test/stream-server/48041395381658214-kb.json","url":"diberryassetmgrtest.file.core.windows.netfunction-blob-test/stream-server/48041395381658214-kb.json","messaging":true,"instructions":{"container":"function-blob-test","directory":"stream-server"},"blobResults":{"container":"function-blob-test","name":"stream-server/48041395381658214-kb.json","lastModified":"Thu, 01 Aug 2019 02:41:51 GMT","etag":"\"0x8D71629CEDE7A97\"","contentLength":"0","requestId":"d38686a0-b01e-00ac-1312-48f645000000","contentSettings":{"contentMD5":"akupPR70pyMjqtQwXiP+Tg=="}},"result":{"container":"function-blob-test","name":"stream-server/48041395381658214-kb.json","lastModified":"Thu, 01 Aug 2019 02:41:51 GMT","etag":"\"0x8D71629CEDE7A97\"","contentLength":"0","requestId":"d38686a0-b01e-00ac-1312-48f645000000","contentSettings":{"contentMD5":"akupPR70pyMjqtQwXiP+Tg=="}}}

Package Sidebar

Install

npm i azure-storage-upload-file-server

Weekly Downloads

0

Version

0.0.9

License

ISC

Unpacked Size

21.6 kB

Total Files

15

Last publish

Collaborators

  • diberry