Problem in Uploading Image in Azure Blob Storage
i am trying to upload an image to azure blob storage, the problem m facing is the image is getting successfully uploaded but the name of the image on azure is randomly generated by the azure itself, i want to name the image myself from the code
following is the code which i am using
var multer = require('multer')
var MulterAzureStorage = require('multer-azure-storage')
var upload = multer({
storage: new MulterAzureStorage({azureStorageConnectionString:
'DefaultEndpointsProtocol=https;AccountName=mystorageaccount;
AccountKey=mykey;EndpointSuffix=core.windows.net',
containerName: 'photos',
containerSecurity: 'blob',
fileName : ?//how to use this options properties
})
} )
node.js azure express azure-storage multer
add a comment |
i am trying to upload an image to azure blob storage, the problem m facing is the image is getting successfully uploaded but the name of the image on azure is randomly generated by the azure itself, i want to name the image myself from the code
following is the code which i am using
var multer = require('multer')
var MulterAzureStorage = require('multer-azure-storage')
var upload = multer({
storage: new MulterAzureStorage({azureStorageConnectionString:
'DefaultEndpointsProtocol=https;AccountName=mystorageaccount;
AccountKey=mykey;EndpointSuffix=core.windows.net',
containerName: 'photos',
containerSecurity: 'blob',
fileName : ?//how to use this options properties
})
} )
node.js azure express azure-storage multer
Seems like this is a question about multer, and not about Azure Storage. Azure Storage doesn't generate random blob names; looks like this is the default behavior for multer when you don't specify a filename. Perhaps look at the multer DiskStorage documentation, which seems to cover it.
– David Makogon
Dec 28 '18 at 13:36
add a comment |
i am trying to upload an image to azure blob storage, the problem m facing is the image is getting successfully uploaded but the name of the image on azure is randomly generated by the azure itself, i want to name the image myself from the code
following is the code which i am using
var multer = require('multer')
var MulterAzureStorage = require('multer-azure-storage')
var upload = multer({
storage: new MulterAzureStorage({azureStorageConnectionString:
'DefaultEndpointsProtocol=https;AccountName=mystorageaccount;
AccountKey=mykey;EndpointSuffix=core.windows.net',
containerName: 'photos',
containerSecurity: 'blob',
fileName : ?//how to use this options properties
})
} )
node.js azure express azure-storage multer
i am trying to upload an image to azure blob storage, the problem m facing is the image is getting successfully uploaded but the name of the image on azure is randomly generated by the azure itself, i want to name the image myself from the code
following is the code which i am using
var multer = require('multer')
var MulterAzureStorage = require('multer-azure-storage')
var upload = multer({
storage: new MulterAzureStorage({azureStorageConnectionString:
'DefaultEndpointsProtocol=https;AccountName=mystorageaccount;
AccountKey=mykey;EndpointSuffix=core.windows.net',
containerName: 'photos',
containerSecurity: 'blob',
fileName : ?//how to use this options properties
})
} )
node.js azure express azure-storage multer
node.js azure express azure-storage multer
edited Dec 28 '18 at 21:03
Shubham Sawant
asked Dec 28 '18 at 12:54
Shubham SawantShubham Sawant
204
204
Seems like this is a question about multer, and not about Azure Storage. Azure Storage doesn't generate random blob names; looks like this is the default behavior for multer when you don't specify a filename. Perhaps look at the multer DiskStorage documentation, which seems to cover it.
– David Makogon
Dec 28 '18 at 13:36
add a comment |
Seems like this is a question about multer, and not about Azure Storage. Azure Storage doesn't generate random blob names; looks like this is the default behavior for multer when you don't specify a filename. Perhaps look at the multer DiskStorage documentation, which seems to cover it.
– David Makogon
Dec 28 '18 at 13:36
Seems like this is a question about multer, and not about Azure Storage. Azure Storage doesn't generate random blob names; looks like this is the default behavior for multer when you don't specify a filename. Perhaps look at the multer DiskStorage documentation, which seems to cover it.
– David Makogon
Dec 28 '18 at 13:36
Seems like this is a question about multer, and not about Azure Storage. Azure Storage doesn't generate random blob names; looks like this is the default behavior for multer when you don't specify a filename. Perhaps look at the multer DiskStorage documentation, which seems to cover it.
– David Makogon
Dec 28 '18 at 13:36
add a comment |
1 Answer
1
active
oldest
votes
According to the README.md
description of MantaCodeDevs/multer-azure-storage
, the fileName
optional property must be a function which return a custom file name as the blob name stored into Azure Blob Storage.
Otherwise when fileName
is not a function, it will use the default blobName
function below to generate a unique name to avoid naming conflicts.
const blobName = (file) => {
let name = file.fieldname + '-' + uuid.v4() + path.extname(file.originalname)
file.blobName = name
return name
}
So I test it with my sample code below, it works for uploading a 1.png
file as blob into Azure Blob Storage.
var getFileName = function() {
return '1.png';
}
var upload = multer({
storage: new MulterAzureStorage({
azureStorageConnectionString: 'DefaultEndpointsProtocol=https;AccountName=<your account name>;AccountKey=<your account key>;EndpointSuffix=core.windows.net',
containerName: 'test',
containerSecurity: 'blob',
fileName: getFileName
})
});
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53958935%2fproblem-in-uploading-image-in-azure-blob-storage%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
According to the README.md
description of MantaCodeDevs/multer-azure-storage
, the fileName
optional property must be a function which return a custom file name as the blob name stored into Azure Blob Storage.
Otherwise when fileName
is not a function, it will use the default blobName
function below to generate a unique name to avoid naming conflicts.
const blobName = (file) => {
let name = file.fieldname + '-' + uuid.v4() + path.extname(file.originalname)
file.blobName = name
return name
}
So I test it with my sample code below, it works for uploading a 1.png
file as blob into Azure Blob Storage.
var getFileName = function() {
return '1.png';
}
var upload = multer({
storage: new MulterAzureStorage({
azureStorageConnectionString: 'DefaultEndpointsProtocol=https;AccountName=<your account name>;AccountKey=<your account key>;EndpointSuffix=core.windows.net',
containerName: 'test',
containerSecurity: 'blob',
fileName: getFileName
})
});
add a comment |
According to the README.md
description of MantaCodeDevs/multer-azure-storage
, the fileName
optional property must be a function which return a custom file name as the blob name stored into Azure Blob Storage.
Otherwise when fileName
is not a function, it will use the default blobName
function below to generate a unique name to avoid naming conflicts.
const blobName = (file) => {
let name = file.fieldname + '-' + uuid.v4() + path.extname(file.originalname)
file.blobName = name
return name
}
So I test it with my sample code below, it works for uploading a 1.png
file as blob into Azure Blob Storage.
var getFileName = function() {
return '1.png';
}
var upload = multer({
storage: new MulterAzureStorage({
azureStorageConnectionString: 'DefaultEndpointsProtocol=https;AccountName=<your account name>;AccountKey=<your account key>;EndpointSuffix=core.windows.net',
containerName: 'test',
containerSecurity: 'blob',
fileName: getFileName
})
});
add a comment |
According to the README.md
description of MantaCodeDevs/multer-azure-storage
, the fileName
optional property must be a function which return a custom file name as the blob name stored into Azure Blob Storage.
Otherwise when fileName
is not a function, it will use the default blobName
function below to generate a unique name to avoid naming conflicts.
const blobName = (file) => {
let name = file.fieldname + '-' + uuid.v4() + path.extname(file.originalname)
file.blobName = name
return name
}
So I test it with my sample code below, it works for uploading a 1.png
file as blob into Azure Blob Storage.
var getFileName = function() {
return '1.png';
}
var upload = multer({
storage: new MulterAzureStorage({
azureStorageConnectionString: 'DefaultEndpointsProtocol=https;AccountName=<your account name>;AccountKey=<your account key>;EndpointSuffix=core.windows.net',
containerName: 'test',
containerSecurity: 'blob',
fileName: getFileName
})
});
According to the README.md
description of MantaCodeDevs/multer-azure-storage
, the fileName
optional property must be a function which return a custom file name as the blob name stored into Azure Blob Storage.
Otherwise when fileName
is not a function, it will use the default blobName
function below to generate a unique name to avoid naming conflicts.
const blobName = (file) => {
let name = file.fieldname + '-' + uuid.v4() + path.extname(file.originalname)
file.blobName = name
return name
}
So I test it with my sample code below, it works for uploading a 1.png
file as blob into Azure Blob Storage.
var getFileName = function() {
return '1.png';
}
var upload = multer({
storage: new MulterAzureStorage({
azureStorageConnectionString: 'DefaultEndpointsProtocol=https;AccountName=<your account name>;AccountKey=<your account key>;EndpointSuffix=core.windows.net',
containerName: 'test',
containerSecurity: 'blob',
fileName: getFileName
})
});
edited Dec 31 '18 at 7:20
answered Dec 31 '18 at 7:14
Peter PanPeter Pan
10.9k3823
10.9k3823
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53958935%2fproblem-in-uploading-image-in-azure-blob-storage%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Seems like this is a question about multer, and not about Azure Storage. Azure Storage doesn't generate random blob names; looks like this is the default behavior for multer when you don't specify a filename. Perhaps look at the multer DiskStorage documentation, which seems to cover it.
– David Makogon
Dec 28 '18 at 13:36